Implement server rotation for classworks cloud provider
Co-authored-by: Sunwuyuan <88357633+Sunwuyuan@users.noreply.github.com>
This commit is contained in:
co-authored by
Sunwuyuan
parent
f8f1b5d494
commit
bf9ff52ee0
+12
-2
@@ -1,5 +1,6 @@
|
||||
import axios from "@/axios/axios";
|
||||
import {getSetting} from "@/utils/settings";
|
||||
import {tryWithRotation, isRotationEnabled} from "@/utils/serverRotation";
|
||||
|
||||
// Helper function to check if provider is valid for API calls
|
||||
const isValidProvider = () => {
|
||||
@@ -33,9 +34,18 @@ export const getNamespaceInfo = async () => {
|
||||
throw new Error("当前数据提供者不支持此操作");
|
||||
}
|
||||
|
||||
const serverUrl = getSetting("server.domain");
|
||||
|
||||
try {
|
||||
// Use rotation for classworkscloud provider
|
||||
if (isRotationEnabled()) {
|
||||
const response = await tryWithRotation(async (serverUrl) => {
|
||||
return await axios.get(`${serverUrl}/kv/_info`, {
|
||||
headers: getHeaders(),
|
||||
});
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
const serverUrl = getSetting("server.domain");
|
||||
const response = await axios.get(`${serverUrl}/kv/_info`, {
|
||||
headers: getHeaders(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user