mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-11 03:39:49 +08:00
feat: add routing profile scheduling policies
This commit is contained in:
@@ -14,6 +14,8 @@ mod observability_families;
|
||||
mod operations_families;
|
||||
#[path = "admin/provider_ops_routes.rs"]
|
||||
mod provider_ops_routes;
|
||||
#[path = "admin/routing_families.rs"]
|
||||
mod routing_families;
|
||||
#[path = "admin/system_families.rs"]
|
||||
mod system_families;
|
||||
|
||||
@@ -23,6 +25,7 @@ use model_provider_families::classify_admin_model_provider_family_route;
|
||||
use observability_families::classify_admin_observability_family_route;
|
||||
use operations_families::classify_admin_operations_family_route;
|
||||
use provider_ops_routes::classify_admin_provider_ops_routes;
|
||||
use routing_families::classify_admin_routing_family_route;
|
||||
use system_families::classify_admin_system_family_route;
|
||||
|
||||
pub(super) fn classify_admin_route(
|
||||
@@ -67,6 +70,10 @@ pub(super) fn classify_admin_route(
|
||||
classify_admin_system_family_route(method, normalized_path, normalized_path_no_trailing)
|
||||
{
|
||||
Some(route)
|
||||
} else if let Some(route) =
|
||||
classify_admin_routing_family_route(method, normalized_path_no_trailing)
|
||||
{
|
||||
Some(route)
|
||||
} else if let Some(route) = classify_admin_provider_ops_routes(method, normalized_path) {
|
||||
Some(route)
|
||||
} else if let Some(route) = classify_admin_model_provider_family_route(method, normalized_path)
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
use axum::http;
|
||||
|
||||
use super::{classified, ClassifiedRoute};
|
||||
|
||||
pub(super) fn classify_admin_routing_family_route(
|
||||
method: &http::Method,
|
||||
normalized_path_no_trailing: &str,
|
||||
) -> Option<ClassifiedRoute> {
|
||||
let path = normalized_path_no_trailing;
|
||||
if method == http::Method::GET && path == "/api/admin/routing/groups" {
|
||||
Some(routing_route("list_groups"))
|
||||
} else if method == http::Method::POST && path == "/api/admin/routing/groups" {
|
||||
Some(routing_route("create_group"))
|
||||
} else if method == http::Method::GET
|
||||
&& path.starts_with("/api/admin/routing/groups/")
|
||||
&& path.ends_with("/versions")
|
||||
&& path.matches('/').count() == 6
|
||||
{
|
||||
Some(routing_route("list_group_versions"))
|
||||
} else if method == http::Method::POST
|
||||
&& path.starts_with("/api/admin/routing/groups/")
|
||||
&& path.ends_with("/publish")
|
||||
&& path.matches('/').count() == 6
|
||||
{
|
||||
Some(routing_route("publish_group"))
|
||||
} else if method == http::Method::POST
|
||||
&& path.starts_with("/api/admin/routing/groups/")
|
||||
&& path.ends_with("/dry-run")
|
||||
&& path.matches('/').count() == 6
|
||||
{
|
||||
Some(routing_route("dry_run_group"))
|
||||
} else if method == http::Method::GET
|
||||
&& path.starts_with("/api/admin/routing/groups/")
|
||||
&& path.matches('/').count() == 5
|
||||
{
|
||||
Some(routing_route("get_group"))
|
||||
} else if method == http::Method::PATCH
|
||||
&& path.starts_with("/api/admin/routing/groups/")
|
||||
&& path.matches('/').count() == 5
|
||||
{
|
||||
Some(routing_route("update_group"))
|
||||
} else if method == http::Method::DELETE
|
||||
&& path.starts_with("/api/admin/routing/groups/")
|
||||
&& path.matches('/').count() == 5
|
||||
{
|
||||
Some(routing_route("delete_group"))
|
||||
} else if method == http::Method::GET && path == "/api/admin/routing/bindings" {
|
||||
Some(routing_route("list_bindings"))
|
||||
} else if method == http::Method::POST && path == "/api/admin/routing/bindings" {
|
||||
Some(routing_route("create_binding"))
|
||||
} else if method == http::Method::PATCH
|
||||
&& path.starts_with("/api/admin/routing/bindings/")
|
||||
&& path.matches('/').count() == 5
|
||||
{
|
||||
Some(routing_route("update_binding"))
|
||||
} else if method == http::Method::DELETE
|
||||
&& path.starts_with("/api/admin/routing/bindings/")
|
||||
&& path.matches('/').count() == 5
|
||||
{
|
||||
Some(routing_route("delete_binding"))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn routing_route(route_kind: &'static str) -> ClassifiedRoute {
|
||||
classified(
|
||||
"admin_proxy",
|
||||
"routing_profiles_manage",
|
||||
route_kind,
|
||||
"admin:routing_profiles",
|
||||
false,
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user