-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3af3a58
commit 109068a
Showing
8 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
from .connect import connect_router | ||
from .info import info_router | ||
from .user import user_router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from fastapi import APIRouter, HTTPException | ||
|
||
from hub_dbs.main_db import ClusterManager, ServerManager | ||
|
||
connect_router = APIRouter(prefix="/api_v1/connect") | ||
|
||
|
||
@connect_router.get("/{full_path}") | ||
async def connect(full_path: str): | ||
try: | ||
type_connect, name = full_path.split(".") | ||
|
||
except ValueError: | ||
raise HTTPException(status_code=400, detail="Invalid format. Use 'type.name'.") | ||
|
||
result = None | ||
if type_connect == "cluster": | ||
result = await ClusterManager.get_least_loaded_server(name) | ||
|
||
elif type_connect == "single": | ||
result = await ServerManager.get_server_info(name) | ||
|
||
if result is None: | ||
raise HTTPException(status_code=404, detail=f"{type_connect}.{name} not found") | ||
|
||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from fastapi import APIRouter | ||
|
||
from hub_dbs.main_db import ServerManager | ||
|
||
info_router = APIRouter(prefix='/api_v1/') | ||
|
||
|
||
@info_router.get("/") | ||
async def get_servers(): | ||
return await ServerManager.get_all_active_servers() | ||
|
||
|
||
@info_router.get("/ping") | ||
async def ping(): | ||
return {"message": "pong!"} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters