feat(routing): add formal chat route endpoint

This commit is contained in:
phamnazage-jpg
2026-05-29 13:17:56 +08:00
parent 09b43ce2d8
commit ecdeedb103
4 changed files with 325 additions and 3 deletions

View File

@@ -32,6 +32,7 @@ type ResolveRouteInfo struct {
StickyKey string `json:"sticky_key"`
StickyHit bool `json:"sticky_hit"`
StickyAction string `json:"sticky_action"`
FallbackUsed bool `json:"fallback_used,omitempty"`
RouteID string `json:"route_id"`
RouteName string `json:"route_name,omitempty"`
ShadowGroupID string `json:"shadow_group_id"`
@@ -116,7 +117,7 @@ func buildResolveRouteAction(sqliteDSN string, stickyRuntime stickyStoreRuntime,
return ResolveRouteInfo{}, err
}
} else {
info := resolveRouteInfoFromBinding(stickyRuntime.backend, stickyKey, req.Scope, req.SubjectID, candidate, binding, requestID, true, "hit")
info := resolveRouteInfoFromBinding(stickyRuntime.backend, stickyKey, req.Scope, req.SubjectID, candidate, binding, requestID, true, "hit", false)
if err := writer.AppendStickyAudit(ctx, routing.RouteStickyAuditEvent{
StickyKey: stickyKey,
StickyKeyType: req.Scope,
@@ -222,7 +223,7 @@ func buildResolveRouteAction(sqliteDSN string, stickyRuntime stickyStoreRuntime,
return ResolveRouteInfo{}, err
}
}
return resolveRouteInfoFromBinding(stickyRuntime.backend, stickyKey, req.Scope, req.SubjectID, candidate, stored, requestID, false, "bind"), nil
return resolveRouteInfoFromBinding(stickyRuntime.backend, stickyKey, req.Scope, req.SubjectID, candidate, stored, requestID, false, "bind", selection.fallbackUsed), nil
}
}
@@ -399,7 +400,7 @@ func resolveStickyTTL(group sqlite.LogicalGroup, scope string) (time.Duration, e
}
}
func resolveRouteInfoFromBinding(backend string, stickyKey string, scope string, subjectID string, candidate resolvedRouteCandidate, binding routing.StickyBinding, requestID string, stickyHit bool, stickyAction string) ResolveRouteInfo {
func resolveRouteInfoFromBinding(backend string, stickyKey string, scope string, subjectID string, candidate resolvedRouteCandidate, binding routing.StickyBinding, requestID string, stickyHit bool, stickyAction string, fallbackUsed bool) ResolveRouteInfo {
return ResolveRouteInfo{
RequestID: requestID,
Backend: backend,
@@ -410,6 +411,7 @@ func resolveRouteInfoFromBinding(backend string, stickyKey string, scope string,
StickyKey: stickyKey,
StickyHit: stickyHit,
StickyAction: stickyAction,
FallbackUsed: fallbackUsed,
RouteID: candidate.route.RouteID,
RouteName: candidate.route.Name,
ShadowGroupID: candidate.route.ShadowGroupID,