Documentation
¶
Overview ¶
Package discovery provides service discovery backends for the gateway.
Available providers:
- StaticProvider: loads endpoints from a YAML config file (for standalone/Docker mode)
- KubernetesProvider: watches Pods and ModelAdapters via K8s informers
TODO: Add ConsulProvider, EtcdProvider.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventHandler ¶ added in v0.7.0
type EventHandler func(event WatchEvent)
EventHandler is a callback invoked by a provider when a resource changes.
type KubernetesProvider ¶ added in v0.7.0
type KubernetesProvider struct {
// contains filtered or unexported fields
}
KubernetesProvider implements Provider using Kubernetes informers.
func NewKubernetesProvider ¶ added in v0.7.0
func NewKubernetesProvider(config *rest.Config) *KubernetesProvider
NewKubernetesProvider creates a new Kubernetes discovery provider.
func (*KubernetesProvider) Type ¶ added in v0.7.0
func (p *KubernetesProvider) Type() string
Type returns the provider type identifier.
func (*KubernetesProvider) Watch ¶ added in v0.7.0
func (p *KubernetesProvider) Watch(handler EventHandler, stopCh <-chan struct{}) error
Watch starts K8s informers with the handler wired directly into informer callbacks. Watch returns once the initial sync and reconcile are complete. After return, informer callbacks continue delivering ongoing changes asynchronously.
type Provider ¶
type Provider interface {
// Watch registers a handler for resource change events and starts watching.
// The provider calls handler for each change (add/update/delete).
//
// Watch should return once the provider has reached a consistent ready state
// (e.g., initial sync complete, config loaded). After return, dynamic providers
// continue delivering ongoing changes via the handler asynchronously.
//
// Static providers deliver initial state and return (no ongoing changes).
// K8s provider lets informers deliver events directly via the handler from
// the start, then does a post-sync reconcile before returning.
// Consul/etcd providers may deliver initial state, then start a background
// watch/poll loop.
Watch(handler EventHandler, stopCh <-chan struct{}) error
// Type returns a string identifier for the provider type (e.g., "static", "consul").
Type() string
}
Provider defines the interface for service discovery backends.
All initial state and ongoing changes are delivered through Watch() via the EventHandler callback.
type RoleSetConfig ¶ added in v0.7.0
type RoleSetConfig struct {
// Name identifies this roleset (used as pairing key in PD routing).
Name string `json:"name"`
// Prefill lists prefill worker addresses in "host:port" format.
Prefill []string `json:"prefill"`
// Decode lists decode worker addresses in "host:port" format.
Decode []string `json:"decode"`
}
RoleSetConfig defines a group of prefill and decode workers that can be paired together. The PD routing algorithm scores prefill and decode pods within the same roleset to find the optimal pair (e.g., Single node P/D etc).
type StaticConfig ¶ added in v0.7.0
type StaticConfig struct {
// Models is the list of models and their workers.
Models []StaticModelConfig `json:"models"`
}
StaticConfig represents the complete static endpoints configuration.
type StaticModelConfig ¶ added in v0.7.0
type StaticModelConfig struct {
// Name is the model name (e.g., "Qwen/Qwen2.5-72B").
Name string `json:"name"`
// Engine is the inference engine type (e.g., "vllm", "sglang", "trtllm"). Optional.
Engine string `json:"engine,omitempty"`
// Endpoints lists worker addresses for non-disaggregated serving.
// Each entry is a "host:port" string. Mutually exclusive with RoleSets.
Endpoints []string `json:"endpoints,omitempty"`
// RoleSets defines prefill/decode worker groups for disaggregated serving.
// Mutually exclusive with Endpoints.
RoleSets []RoleSetConfig `json:"rolesets,omitempty"`
}
StaticModelConfig represents a model and its backend workers.
type StaticProvider ¶ added in v0.7.0
type StaticProvider struct {
// contains filtered or unexported fields
}
StaticProvider implements Provider by loading a static YAML configuration file. The configuration is loaded once at startup; no dynamic updates are supported.
func NewStaticProvider ¶ added in v0.7.0
func NewStaticProvider(configPath string) *StaticProvider
NewStaticProvider creates a new static discovery provider.
func (*StaticProvider) Type ¶ added in v0.7.0
func (p *StaticProvider) Type() string
Type returns the provider type identifier.
func (*StaticProvider) Watch ¶ added in v0.7.0
func (p *StaticProvider) Watch(handler EventHandler, _ <-chan struct{}) error
Watch reads the config file, delivers all endpoints as EventAdd via the handler, and returns. Static provider has no ongoing dynamic updates.
type WatchEvent ¶ added in v0.7.0
type WatchEvent struct {
// Type is the kind of change: add, update, or delete.
Type EventType
// Object is the current state of the resource (for add/update) or
// the last known state (for delete). Currently *v1.Pod.
Object any
// OldObject is the previous state, only set for EventUpdate. Nil otherwise.
OldObject any
}
WatchEvent represents a change detected by a discovery provider.