Documentation
¶
Index ¶
- Constants
- Variables
- func GetModelTag(model string) string
- func GetTraceID(traceparent, requestID string) string
- func HasRequestBuffers(requestID string) bool
- func StreamPanicRecoveryInterceptor() grpc.StreamServerInterceptor
- type AsyncJobListOptions
- type AsyncJobListPage
- type AsyncJobPodTarget
- type AsyncJobRecord
- type AsyncJobRegistration
- type AsyncJobRegistry
- type AsyncJobRoutingTarget
- type MockCache
- func (m *MockCache) AddRequestCount(ctx *types.RoutingContext, requestID string, model string) int64
- func (m *MockCache) AddSubscriber(subscriber metrics.MetricSubscriber)
- func (m *MockCache) AdmitPodRunningRequest(podName string, podNamespace string, limit int64) (bool, error)
- func (m *MockCache) DoneRequestCount(ctx *types.RoutingContext, requestID string, model string, term int64)
- func (m *MockCache) DoneRequestTrace(ctx *types.RoutingContext, requestID string, model string, inputTokens int64, ...)
- func (m *MockCache) GetMetricValueByPod(namespace string, podName string, metricName string) (metrics.MetricValue, error)
- func (m *MockCache) GetMetricValueByPodModel(namespace string, podName string, model string, metricName string) (metrics.MetricValue, error)
- func (m *MockCache) GetPod(namespace string, podName string) (*v1.Pod, error)
- func (m *MockCache) GetPodRunningRequests(podName string, podNamespace string) (int64, error)
- func (m *MockCache) GetPodsRunningRequests(pods []*v1.Pod) (map[string]int64, error)
- func (m *MockCache) HasModel(model string) bool
- func (m *MockCache) ListModels() []string
- func (m *MockCache) ListModelsByPod(namespace string, podName string) ([]string, error)
- func (m *MockCache) ListPodsByModel(model string) (types.PodList, error)
- func (m *MockCache) ModelBaseModel(model string) (string, bool)
- func (m *MockCache) ModelClaimBinding(model string) (*v1.Pod, utils.ModelClaimBinding, bool)
- func (m *MockCache) ModelClaimStatus(model string) (string, string, bool)
- func (m *MockCache) RegisterRequestTracker(tracker cache.RequestTracker)
- type MockGatewayClassClient
- type MockGatewayClient
- func (m *MockGatewayClient) Discovery() discovery.DiscoveryInterface
- func (m *MockGatewayClient) GatewayV1() gatewayapiv1.GatewayV1Interface
- func (m *MockGatewayClient) GatewayV1alpha2() gatewayapiv1alpha2.GatewayV1alpha2Interface
- func (m *MockGatewayClient) GatewayV1beta1() gatewayapiv1beta1.GatewayV1beta1Interface
- type MockGatewayV1Client
- func (m *MockGatewayV1Client) GatewayClasses() gatewayapiv1.GatewayClassInterface
- func (m *MockGatewayV1Client) Gateways(namespace string) gatewayapiv1.GatewayInterface
- func (m *MockGatewayV1Client) HTTPRoutes(namespace string) gatewayapiv1.HTTPRouteInterface
- func (m *MockGatewayV1Client) RESTClient() rest.Interface
- type MockHTTPRouteClient
- func (m *MockHTTPRouteClient) Create(ctx context.Context, httpRoute *gatewayv1.HTTPRoute, opts metav1.CreateOptions) (*gatewayv1.HTTPRoute, error)
- func (m *MockHTTPRouteClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
- func (m *MockHTTPRouteClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error
- func (m *MockHTTPRouteClient) Get(ctx context.Context, name string, opts metav1.GetOptions) (*gatewayv1.HTTPRoute, error)
- func (m *MockHTTPRouteClient) List(ctx context.Context, opts metav1.ListOptions) (*gatewayv1.HTTPRouteList, error)
- func (m *MockHTTPRouteClient) Patch(ctx context.Context, name string, pt k8stype.PatchType, data []byte, ...) (result *gatewayv1.HTTPRoute, err error)
- func (m *MockHTTPRouteClient) Update(ctx context.Context, httpRoute *gatewayv1.HTTPRoute, opts metav1.UpdateOptions) (*gatewayv1.HTTPRoute, error)
- func (m *MockHTTPRouteClient) UpdateStatus(ctx context.Context, httpRoute *gatewayv1.HTTPRoute, opts metav1.UpdateOptions) (*gatewayv1.HTTPRoute, error)
- func (m *MockHTTPRouteClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
- type ModelListGate
- type ModelListMode
- type OpenAIResponse
- type Server
- func (s *Server) HandleRequestBody(ctx context.Context, routingCtx *types.RoutingContext, requestID string, ...) (*extProcPb.ProcessingResponse, string, bool, int64)
- func (s *Server) HandleRequestHeaders(ctx context.Context, requestID string, rootSpan trace.Span, ...) (*extProcPb.ProcessingResponse, utils.User, int64, *types.RoutingContext, int64)
- func (s *Server) HandleResponseBody(ctx context.Context, routerCtx *types.RoutingContext, requestID string, ...) (*extProcPb.ProcessingResponse, bool, TokenUsage)
- func (s *Server) HandleResponseHeaders(ctx context.Context, routerCtx *types.RoutingContext, requestID string, ...) (*extProcPb.ProcessingResponse, bool, int)
- func (s *Server) Process(srv extProcPb.ExternalProcessor_ProcessServer) (err error)
- func (s *Server) Shutdown()
- func (s *Server) StartHTTPServer(addr string) error
- type ServerOptions
- type TokenUsage
Constants ¶
const ( HeaderErrorInvalidRouting = "x-error-invalid-routing-strategy" // General Error Headers HeaderErrorUser = "x-error-user" HeaderErrorRouting = "x-error-routing" HeaderErrorRequestBodyProcessing = "x-error-request-body-processing" HeaderErrorResponseUnmarshal = "x-error-response-unmarshal" HeaderErrorResponseUnknown = "x-error-response-unknown" // HeaderErrorPDPrefill marks a response the gateway generated because the // prefill leg of a PD request failed, so the failure is distinguishable // from a 5xx the decode pod produced itself. HeaderErrorPDPrefill = "x-error-pd-prefill" // HeaderErrorPDDecode marks a response the gateway generated because the // decode leg of a PD request stopped responding after its prefill leg // succeeded (the decode watchdog). HeaderErrorPDDecode = "x-error-pd-decode" // Model & Deployment Headers HeaderErrorNoModelInRequest = "x-error-no-model-in-request" HeaderErrorNoModelBackends = "x-error-no-model-backends" // Streaming Headers HeaderErrorStream = "x-error-stream" HeaderErrorStreaming = "x-error-streaming" HeaderErrorStreamOptionsIncludeUsage = "x-error-no-stream-options-include-usage" // Multipart/Audio Headers HeaderErrorMultipartParsing = "x-error-multipart-parsing" // Video Job Headers HeaderErrorVideoNotFound = "x-error-video-not-found" // Request & Target Headers HeaderWentIntoReqHeaders = "x-went-into-req-headers" HeaderTargetPodIP = "target-pod-ip" HeaderTargetPod = "target-pod" HeaderRoutingStrategy = "routing-strategy" HeaderRequestID = "request-id" HeaderModel = "model" HeaderExternalFilter = "external-filter" HeaderConfigProfile = "config-profile" HeaderAIBrixConfigProfile = "x-aibrix-config-profile" // HeaderPriorityTier declares the priority tier of the request (for // example batch or background) so the gateway can map it to the upstream // vLLM request priority. See gateway_req_priority.go. HeaderPriorityTier = "x-aibrix-priority-tier" // HeaderSessionID aliases the shared session-affinity header used by request parsing and routing. HeaderSessionID = constants.HeaderSessionID // HeaderSessionKey aliases the shared opaque session-key header. HeaderSessionKey = constants.HeaderSessionKey HeaderTraceParent = "traceparent" // HeaderMockPDFailure is a test-only header forwarded to mock PD backends. HeaderMockPDFailure = "x-aibrix-mock-fail" // RPM & TPM Update Errors HeaderUpdateTPM = "x-update-tpm" HeaderUpdateRPM = "x-update-rpm" HeaderErrorRPMExceeded = "x-error-rpm-exceeded" HeaderErrorTPMExceeded = "x-error-tpm-exceeded" HeaderErrorIncrRPM = "x-error-incr-rpm" HeaderErrorIncrTPM = "x-error-incr-tpm" // Model RPS Errors HeaderErrorModelRPSExceeded = "x-error-model-rps-exceeded" HeaderErrorIncrModelRPS = "x-error-incr-model-rps" // Per-replica inflight Errors HeaderErrorReplicaInflightExceeded = "x-error-model-replica-inflight-exceeded" // Rate Limiting defaults DefaultRPM = 100 DefaultTPMMultiplier = 1000 // Envs EnvRoutingAlgorithm = "ROUTING_ALGORITHM" // OpenAI Error Types ErrorTypeInvalidRequest = "invalid_request_error" ErrorTypeAuthentication = "authentication_error" ErrorTypeRateLimit = "rate_limit_error" ErrorTypeApi = "api_error" ErrorTypeOverloaded = "overloaded_error" // OpenAI Error Codes ErrorCodeInvalidAPIKey = "invalid_api_key" ErrorCodeModelNotFound = "model_not_found" ErrorCodeRateLimitExceeded = "rate_limit_exceeded" ErrorCodeExternalPolicyDenied = "external_policy_denied" ErrorCodeVideoNotFound = "video_not_found" ErrorCodeReplicaInflightExceeded = "replica_inflight_exceeded" ErrorCodeUnsupportedRoutingStrategy = "unsupported_routing_strategy" // Embedding Constraints // https://github.com/openai/openai-go/blob/main/embedding.go#L126 // // The token-count limits from that reference (8192 per input, 300000 per // batch) are not enforced here: they are denominated in the target model's // tokens, which the gateway cannot measure. See validateStringInputs. MaxArrayDimensions = 2048 // Request Paths PathChatCompletions = "/v1/chat/completions" PathResponses = "/v1/responses" PathMessages = "/v1/messages" PathMessagesCountTokens = "/v1/messages/count_tokens" PathCompletions = "/v1/completions" PathEmbeddings = "/v1/embeddings" PathImagesGenerations = "/v1/images/generations" PathVideoGenerations = "/v1/video/generations" PathAudioTranscriptions = "/v1/audio/transcriptions" PathAudioTranslations = "/v1/audio/translations" PathRerank = "/v1/rerank" PathClassify = "/v1/classify" // PathNativeClassify is where vLLM serves classification; PathClassify is SGLang's // OpenAI-style route. PathNativeClassify = "/classify" // PathDecisions is SGLang's typed-question scoring endpoint (choice, score, yes_no). // It does not stream and generates no tokens. PathDecisions = "/v1/decisions" // PathSystemOne is SGLang's System One compatible form of PathDecisions: a "state" and a // map of noul, choice and score questions keyed by caller ids. It does not stream, and its // usage reports input_tokens/output_tokens with no total. PathSystemOne = "/v1/systemone" // PathScore is SGLang's scoring endpoint: label-token probabilities or classifier // logits for each query/item pair, pointwise or setwise. It does not stream. PathScore = "/v1/score" // PathVideos and PathVideosSync are vLLM-Omni's native Videos API (multipart/form-data), // distinct from the OpenAI/Sora-shaped PathVideoGenerations (JSON) above. PathVideos also // covers its GET/DELETE sub-resources (/v1/videos/{id}, /v1/videos/{id}/content) via // prefix matching in isLanguageRequest and extractVideoIDFromPath. PathVideos = "/v1/videos" PathVideosSync = "/v1/videos/sync" PathTokenize = "/tokenize" PathPooling = "/pooling" // Engine-specific paths (xdit) PathXditGenerate = "/generate" PathXditGenerateVideo = "/generatevideo" // Engine Types EngineXdit = "xdit" )
const ProcessFullMethod = "/envoy.service.ext_proc.v3.ExternalProcessor/Process"
ProcessFullMethod is the ExtProc method Envoy calls for every request. Process reports it when it recovers a panic on its own, without the stream interceptor that normally wraps it.
Variables ¶
var (
ErrorUnknownResponse = errors.New("unknown response")
)
var (
POD_NAME = os.Getenv("POD_NAME")
)
Functions ¶
func GetModelTag ¶ added in v0.6.0
func GetTraceID ¶ added in v0.7.0
func HasRequestBuffers ¶ added in v0.8.0
HasRequestBuffers is a test-observation API: it reports whether an in-flight request retains body state in either production buffer. sync.Map makes the point-in-time lookup safe concurrently with Process cleanup; callers should invoke it after Process returns when asserting terminal cleanup.
func StreamPanicRecoveryInterceptor ¶ added in v0.8.0
func StreamPanicRecoveryInterceptor() grpc.StreamServerInterceptor
StreamPanicRecoveryInterceptor recovers panics raised while a stream handler runs. Without it a single defective request ends the gateway plugin process and every request in flight on it; with it the stream that panicked fails with codes.Internal and the rest of the server keeps serving.
Recovering here is a last line of defense, not a replacement for fixing the defect: the stack trace is logged and the panic is counted, so the condition stays visible instead of being swallowed.
Types ¶
type AsyncJobListOptions ¶ added in v0.8.0
AsyncJobListOptions describes one cursor page of an owner's jobs. After is the last public id from the previous page and must still be present in the owner's catalog; a deleted or expired cursor is invalid, and the caller must restart from the first page. Order is "asc" or "desc" by creation time. Limit is validated by the caller or the store before use.
type AsyncJobListPage ¶ added in v0.8.0
type AsyncJobListPage struct {
Records []AsyncJobRecord
HasMore bool
}
AsyncJobListPage is the registry result used to build OpenAI-style list envelopes without exposing backend job ids or routing targets.
type AsyncJobPodTarget ¶ added in v0.8.0
type AsyncJobPodTarget struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
UID string `json:"uid"`
}
AsyncJobPodTarget identifies the pod that accepted a job. The UID is part of the identity on purpose: a pod recreated under the same name is a different pod, and the job's output does not exist on its disk.
type AsyncJobRecord ¶ added in v0.8.0
type AsyncJobRecord struct {
PublicJobID string `json:"public_job_id"`
JobType string `json:"job_type"`
Owner string `json:"owner"`
Model string `json:"model"`
BackendJobID string `json:"backend_job_id"`
RoutingTarget AsyncJobRoutingTarget `json:"routing_target"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
}
AsyncJobRecord is everything the gateway remembers about an asynchronous job.
type AsyncJobRegistration ¶ added in v0.8.0
type AsyncJobRegistration struct {
JobType string
Owner string
Model string
BackendJobID string
Pod *v1.Pod
// ExpiresAt is the backend's own expiry when it reported one, and is used
// exactly as reported. Only an absent expiry gets defaultAsyncJobTTL; an
// expiry that has already elapsed is refused rather than extended.
ExpiresAt time.Time
}
AsyncJobRegistration is the caller's view of a job that a backend has just accepted. The public id and timestamps are the registry's to decide.
type AsyncJobRegistry ¶ added in v0.8.0
type AsyncJobRegistry interface {
Register(ctx context.Context, reg AsyncJobRegistration) (AsyncJobRecord, error)
Get(ctx context.Context, owner, publicJobID string) (AsyncJobRecord, *v1.Pod, error)
List(ctx context.Context, owner, jobType string, options AsyncJobListOptions) (AsyncJobListPage, error)
Delete(ctx context.Context, owner, publicJobID string) error
}
AsyncJobRegistry maps opaque public job ids to the backend job id and the pod that owns it. Every operation is scoped to an owner, and pod resolution is an internal step of Get so no caller can route on a record it does not own.
The gateway depends on this interface rather than a storage implementation. Tests use memoryAsyncJobRegistry, while production uses redisAsyncJobRegistry so records are visible to every gateway replica.
type AsyncJobRoutingTarget ¶ added in v0.8.0
type AsyncJobRoutingTarget struct {
Kind string `json:"kind"`
Pod AsyncJobPodTarget `json:"pod"`
}
AsyncJobRoutingTarget describes where follow-up requests for a job must go.
type MockCache ¶ added in v0.4.0
MockCache implements cache.Cache interface for testing
func (*MockCache) AddRequestCount ¶ added in v0.4.0
func (*MockCache) AddSubscriber ¶ added in v0.4.0
func (m *MockCache) AddSubscriber(subscriber metrics.MetricSubscriber)
func (*MockCache) AdmitPodRunningRequest ¶ added in v0.8.0
func (m *MockCache) AdmitPodRunningRequest(podName string, podNamespace string, limit int64) (bool, error)
AdmitPodRunningRequest defaults to admitting (true, nil) when the test hasn't set up an expectation, mirroring GetPodRunningRequests's harmless-zero-value default -- most tests exercising other behavior don't care about the inflight cap at all.
func (*MockCache) DoneRequestCount ¶ added in v0.4.0
func (*MockCache) DoneRequestTrace ¶ added in v0.4.0
func (*MockCache) GetMetricValueByPod ¶ added in v0.4.0
func (*MockCache) GetMetricValueByPodModel ¶ added in v0.4.0
func (*MockCache) GetPodRunningRequests ¶ added in v0.8.0
func (*MockCache) GetPodsRunningRequests ¶ added in v0.8.0
func (*MockCache) ListModels ¶ added in v0.4.0
func (*MockCache) ListModelsByPod ¶ added in v0.4.0
func (*MockCache) ListPodsByModel ¶ added in v0.4.0
func (*MockCache) ModelBaseModel ¶ added in v0.8.0
ModelBaseModel is called on the request path so LoRA metrics can record both the adapter name and its base model. Default to ("", false).
func (*MockCache) ModelClaimBinding ¶ added in v0.8.0
func (*MockCache) ModelClaimStatus ¶ added in v0.8.0
func (*MockCache) RegisterRequestTracker ¶ added in v0.8.0
func (m *MockCache) RegisterRequestTracker(tracker cache.RequestTracker)
RegisterRequestTracker is a no-op: the pd router registers itself on the injected cache at construction time and the mock does not fan out request lifecycle callbacks.
type MockGatewayClassClient ¶ added in v0.4.0
type MockGatewayClient ¶ added in v0.4.0
MockGatewayClient implements gatewayapi.Clientset interface
func (*MockGatewayClient) Discovery ¶ added in v0.4.0
func (m *MockGatewayClient) Discovery() discovery.DiscoveryInterface
func (*MockGatewayClient) GatewayV1 ¶ added in v0.4.0
func (m *MockGatewayClient) GatewayV1() gatewayapiv1.GatewayV1Interface
func (*MockGatewayClient) GatewayV1alpha2 ¶ added in v0.4.0
func (m *MockGatewayClient) GatewayV1alpha2() gatewayapiv1alpha2.GatewayV1alpha2Interface
func (*MockGatewayClient) GatewayV1beta1 ¶ added in v0.4.0
func (m *MockGatewayClient) GatewayV1beta1() gatewayapiv1beta1.GatewayV1beta1Interface
type MockGatewayV1Client ¶ added in v0.4.0
MockGatewayV1Client implements gatewayapi.Interface
func (*MockGatewayV1Client) GatewayClasses ¶ added in v0.4.0
func (m *MockGatewayV1Client) GatewayClasses() gatewayapiv1.GatewayClassInterface
func (*MockGatewayV1Client) Gateways ¶ added in v0.4.0
func (m *MockGatewayV1Client) Gateways(namespace string) gatewayapiv1.GatewayInterface
func (*MockGatewayV1Client) HTTPRoutes ¶ added in v0.4.0
func (m *MockGatewayV1Client) HTTPRoutes(namespace string) gatewayapiv1.HTTPRouteInterface
func (*MockGatewayV1Client) RESTClient ¶ added in v0.4.0
func (m *MockGatewayV1Client) RESTClient() rest.Interface
type MockHTTPRouteClient ¶ added in v0.4.0
MockHTTPRouteClient implements gatewayapi.HTTPRouteInterface
func (*MockHTTPRouteClient) Create ¶ added in v0.4.0
func (m *MockHTTPRouteClient) Create(ctx context.Context, httpRoute *gatewayv1.HTTPRoute, opts metav1.CreateOptions) (*gatewayv1.HTTPRoute, error)
func (*MockHTTPRouteClient) Delete ¶ added in v0.4.0
func (m *MockHTTPRouteClient) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
func (*MockHTTPRouteClient) DeleteCollection ¶ added in v0.4.0
func (m *MockHTTPRouteClient) DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error
func (*MockHTTPRouteClient) Get ¶ added in v0.4.0
func (m *MockHTTPRouteClient) Get(ctx context.Context, name string, opts metav1.GetOptions) (*gatewayv1.HTTPRoute, error)
func (*MockHTTPRouteClient) List ¶ added in v0.4.0
func (m *MockHTTPRouteClient) List(ctx context.Context, opts metav1.ListOptions) (*gatewayv1.HTTPRouteList, error)
func (*MockHTTPRouteClient) Update ¶ added in v0.4.0
func (m *MockHTTPRouteClient) Update(ctx context.Context, httpRoute *gatewayv1.HTTPRoute, opts metav1.UpdateOptions) (*gatewayv1.HTTPRoute, error)
func (*MockHTTPRouteClient) UpdateStatus ¶ added in v0.4.0
func (m *MockHTTPRouteClient) UpdateStatus(ctx context.Context, httpRoute *gatewayv1.HTTPRoute, opts metav1.UpdateOptions) (*gatewayv1.HTTPRoute, error)
func (*MockHTTPRouteClient) Watch ¶ added in v0.4.0
func (m *MockHTTPRouteClient) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
type ModelListGate ¶ added in v0.8.0
type ModelListGate struct {
// contains filtered or unexported fields
}
ModelListGate serves a 503 while the gateway cache is initially syncing, then delegates to the normal model-list handler. It is used only when discovery verification is explicitly enabled.
func (*ModelListGate) SetServer ¶ added in v0.8.0
func (g *ModelListGate) SetServer(server *Server)
SetServer publishes the ready gateway handler after cache initialization.
func (*ModelListGate) Shutdown ¶ added in v0.8.0
func (g *ModelListGate) Shutdown()
Shutdown stops the early listener after gateway shutdown.
func (*ModelListGate) StartHTTPServer ¶ added in v0.8.0
func (g *ModelListGate) StartHTTPServer(addr string) error
StartHTTPServer opens the model-list and metrics listener before discovery.
type ModelListMode ¶ added in v0.8.0
type ModelListMode string
ModelListMode selects which models the gateway HTTP endpoint lists.
const ( // ModelListKnown preserves the existing behavior: every name in the cache. ModelListKnown ModelListMode = "known" // ModelListReadyPods includes names with at least one ready Pod. ModelListReadyPods ModelListMode = "ready-pods" )
type OpenAIResponse ¶ added in v0.5.0
type OpenAIResponse struct {
Model string `json:"model"`
// Usage carries token accounting. The Chat Completions/Completions APIs report
// prompt_tokens/completion_tokens, while the Responses API (/v1/responses) reports
// the same two semantic values under input_tokens/output_tokens. Both naming pairs
// are therefore aliases for the same concepts:
// prompt_tokens == input_tokens (tokens in the request)
// completion_tokens == output_tokens (tokens generated)
// Only one pair is populated per response depending on the upstream API. Fields are
// pointers so an absent field (nil) is distinguishable from a genuine zero count,
// which lets the prompt/input (and completion/output) fallback select the right alias.
Usage *struct {
PromptTokens *int64 `json:"prompt_tokens"`
CompletionTokens *int64 `json:"completion_tokens"`
TotalTokens *int64 `json:"total_tokens"`
InputTokens *int64 `json:"input_tokens"`
OutputTokens *int64 `json:"output_tokens"`
} `json:"usage"`
Code int `json:"code"`
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(redisClient *redis.Client, client kubernetes.Interface, gatewayClient gatewayapi.Interface) *Server
func NewServerWithOptions ¶ added in v0.8.0
func NewServerWithOptions(redisClient *redis.Client, client kubernetes.Interface, gatewayClient gatewayapi.Interface, options ServerOptions) *Server
NewServerWithOptions constructs a Gateway server with optional dependencies. A supplied Cache without a RouterManager creates an isolated cache-aware manager; with no options, production global cache and routing behavior apply.
func (*Server) HandleRequestBody ¶
func (s *Server) HandleRequestBody(ctx context.Context, routingCtx *types.RoutingContext, requestID string, req *extProcPb.ProcessingRequest, user utils.User) (*extProcPb.ProcessingResponse, string, bool, int64)
func (*Server) HandleRequestHeaders ¶
func (*Server) HandleResponseBody ¶
func (s *Server) HandleResponseBody(ctx context.Context, routerCtx *types.RoutingContext, requestID string, req *extProcPb.ProcessingRequest, user utils.User, rpm int64, model string, stream bool, hasCompleted bool) (*extProcPb.ProcessingResponse, bool, TokenUsage)
HandleResponseBody parses and accounts for a response body but deliberately does not finalize cache bookkeeping or release routerCtx. Process owns that lifecycle and keeps the context valid until its final deferred cleanup.
func (*Server) HandleResponseHeaders ¶
func (s *Server) HandleResponseHeaders(ctx context.Context, routerCtx *types.RoutingContext, requestID string, model string, req *extProcPb.ProcessingRequest) (*extProcPb.ProcessingResponse, bool, int)
HandleResponseHeaders parses upstream headers without finalizing request bookkeeping or releasing routerCtx; Process owns both lifecycle operations.
func (*Server) Process ¶
func (s *Server) Process(srv extProcPb.ExternalProcessor_ProcessServer) (err error)
func (*Server) StartHTTPServer ¶ added in v0.7.0
StartHTTPServer starts the gateway's HTTP server with metrics and API handlers. In local/standalone mode, Envoy routes /v1/models here since there is no metadata service. In standard K8s deployment, Envoy routes /v1/models to the metadata service instead, so the /v1/models handler here is never reached — no conflict.
type ServerOptions ¶ added in v0.8.0
type ServerOptions struct {
Cache cache.Cache
RouterManager *routing.RouterManager
// ModelListMode defaults to ModelListKnown.
ModelListMode ModelListMode
// VerifyModelList returns 503 when a current discovery snapshot cannot be
// established. Off by default for compatibility.
VerifyModelList bool
// DisableRateLimiting disables AIBrix user and model quota enforcement while
// leaving Redis available to other gateway features.
DisableRateLimiting bool
// PriorityTier forwards the tier a request declares through the
// x-aibrix-priority-tier header as the priority on the upstream vLLM
// request. Off by default: requests are forwarded unchanged unless a
// deployment opts in. See gateway_req_priority.go.
PriorityTier bool
// InFlightObserver receives test/diagnostic lifecycle deltas (+1/-1). The
// callback must be non-blocking and non-panicking because it runs on the
// request processing path and is not recovered by Gateway.
InFlightObserver func(int)
}
ServerOptions configures optional dependencies for a Server.
type TokenUsage ¶ added in v0.8.0
TokenUsage contains the token counts reported by an inference response.
Source Files
¶
- api_key_auth.go
- async_job_registry.go
- gateway.go
- gateway_decode_watchdog.go
- gateway_inflight.go
- gateway_model_list_gate.go
- gateway_pd_fail_fast.go
- gateway_ratelimit.go
- gateway_req_body.go
- gateway_req_headers.go
- gateway_req_priority.go
- gateway_rsp_body.go
- gateway_rsp_headers.go
- gateway_test_helpers.go
- gateway_video_routing.go
- json_render.go
- modelclaim_wake.go
- prefix_tools.go
- recovery.go
- types.go
- util.go
Directories
¶
| Path | Synopsis |
|---|---|
|
external
Package external implements the optional HTTP-based replica-selection strategy.
|
Package external implements the optional HTTP-based replica-selection strategy. |
|
pd
Package pd contains the scoring types used by the PD (prefill-decode) disaggregated-inference router.
|
Package pd contains the scoring types used by the PD (prefill-decode) disaggregated-inference router. |
|
pd/selector
Package selector defines the PodSelector contract for PD-disaggregated routing.
|
Package selector defines the PodSelector contract for PD-disaggregated routing. |
|
vtc
Package vtc implements the Virtual Token Counter routing algorithms focused on fairness and utilization
|
Package vtc implements the Virtual Token Counter routing algorithms focused on fairness and utilization |
|
Package configprofiles parses the model.aibrix.ai/config annotation (or ConfigMap) and supports multiple named profiles selectable at runtime via config-profile header.
|
Package configprofiles parses the model.aibrix.ai/config annotation (or ConfigMap) and supports multiple named profiles selectable at runtime via config-profile header. |
|
Package statesync provides a generic Redis-backed state sync layer for use across multiple gateway (or other) replicas.
|
Package statesync provides a generic Redis-backed state sync layer for use across multiple gateway (or other) replicas. |