Documentation
¶
Index ¶
- Variables
- type Authenticator
- type AuthenticatorFunc
- type Authorizer
- type CatalogSource
- type Clock
- type CounterStore
- type Dependencies
- type DisabledResponseCache
- type DiscardTelemetrySink
- type Engine
- func (e *Engine) Authorize(ctx context.Context, principal contract.Principal, publicModel string) error
- func (e *Engine) Drain(ctx context.Context) error
- func (e *Engine) Handler(options HTTPOptions) (http.Handler, error)
- func (e *Engine) Invoke(ctx context.Context, principal contract.Principal, request contract.Request) (contract.Response, error)
- func (e *Engine) Probe(ctx context.Context) (HealthReport, error)
- func (e *Engine) Reload(ctx context.Context) error
- func (e *Engine) Snapshot() (*catalog.Snapshot, error)
- func (e *Engine) Status() Status
- func (e *Engine) Stream(ctx context.Context, principal contract.Principal, request contract.Request) (EventStream, error)
- type EventStream
- type GatewayStream
- type HTTPOptions
- type HealthReport
- type MeteringPort
- type Options
- type RandomSelector
- type ResponseCache
- type SecretResolver
- type Selector
- type Status
- type SystemClock
- type TelemetryEvent
- type TelemetrySink
- type Timer
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Authenticator ¶
type AuthenticatorFunc ¶
func (AuthenticatorFunc) Authenticate ¶
type Authorizer ¶
type CatalogSource ¶
type CounterStore ¶
type CounterStore interface {
// Add atomically increments a disposable protection counter. The first
// successful increment establishes the TTL; later increments must not slide
// the window.
Add(context.Context, string, int64, time.Duration) (int64, error)
Get(context.Context, string) (int64, bool, error)
// Acquire atomically reserves one unit up to maximum and returns an opaque,
// idempotently releasable lease. The aggregate expiry must cover the newest
// lease so live capacity cannot disappear early; TTL bounds leaked capacity
// after a crash.
Acquire(context.Context, string, int64, time.Duration) (string, error)
Release(context.Context, string) error
Delete(context.Context, string) error
}
type Dependencies ¶
type Dependencies struct {
Catalog CatalogSource
Secrets SecretResolver
Adapters *adapter.Registry
Authorizer Authorizer
Metering MeteringPort
Counters CounterStore
Cache ResponseCache
Guardrails *guardrail.Registry
Telemetry TelemetrySink
Selector Selector
Clock Clock
}
type DisabledResponseCache ¶
type DisabledResponseCache struct{}
DisabledResponseCache is an explicit cache opt-out.
func (DisabledResponseCache) Delete ¶
func (DisabledResponseCache) Delete(context.Context, string) error
type DiscardTelemetrySink ¶
type DiscardTelemetrySink struct{}
DiscardTelemetrySink is an explicit opt-out for hosts that do not emit gateway telemetry.
func (DiscardTelemetrySink) Record ¶
func (DiscardTelemetrySink) Record(context.Context, TelemetryEvent)
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) Authorize ¶
func (e *Engine) Authorize(ctx context.Context, principal contract.Principal, publicModel string) error
Authorize evaluates model visibility through the same host policy used by invocation. Protocol handlers use it for discovery without duplicating ACLs.
func (*Engine) Handler ¶
func (e *Engine) Handler(options HTTPOptions) (http.Handler, error)
Handler exposes the engine's supported OpenAI-compatible HTTP routes.
type EventStream ¶
type EventStream = contract.EventStream
type GatewayStream ¶
type GatewayStream struct {
// contains filtered or unexported fields
}
func (*GatewayStream) Next ¶
func (s *GatewayStream) Next(ctx context.Context) (contract.StreamEvent, error)
Next hands the first validated event to the caller and irrevocably commits this stream to its selected deployment. Provider switching is impossible after this method returns an event.
type HTTPOptions ¶
type HTTPOptions struct {
Authenticator Authenticator
Protocol openai.Options
}
HTTPOptions configures the strict OpenAI-compatible HTTP surface. The authenticator is supplied here so hosts that invoke the engine directly do not need to configure an unused HTTP authentication path.
type HealthReport ¶
type MeteringPort ¶
type MeteringPort interface {
Admit(context.Context, contract.Admission) (contract.ReservationToken, error)
Complete(context.Context, contract.Completion) error
Cancel(context.Context, contract.Cancellation) error
}
MeteringPort is implemented by the host. The gateway reports admission and terminal usage facts; the host alone owns policy evaluation and persistence.
type Options ¶
type Options struct {
MaxAttempts int
DefaultMaxOutputTokens int64
FinalizationTimeout time.Duration
BaseRetryDelay time.Duration
MaxRetryDelay time.Duration
CircuitFailures int64
CircuitWindow time.Duration
CircuitCooldown time.Duration
CacheTTL time.Duration
CacheTimeout time.Duration
CacheFillWait time.Duration
MaxCacheEntryBytes int
FirstEventTimeout time.Duration
StreamIdleTimeout time.Duration
RequestTimeout time.Duration
HealthProbeWorkers int
}
type RandomSelector ¶
type RandomSelector struct{}
RandomSelector is the production weighted-route selector. Tests should use an injected deterministic selector instead.
func (RandomSelector) Intn ¶
func (RandomSelector) Intn(limit int) int
type ResponseCache ¶
type SecretResolver ¶
type Status ¶
type Status struct {
Ready bool `json:"ready"`
Draining bool `json:"draining"`
Degraded bool `json:"degraded"`
Revision uint64 `json:"revision"`
ActiveSnapshotAgeSeconds int64 `json:"active_snapshot_age_seconds"`
RejectedRevision uint64 `json:"rejected_revision,omitempty"`
ReloadStage string `json:"reload_stage,omitempty"`
}
Status is a redacted, point-in-time view of engine lifecycle and catalog readiness. Failure stages are stable categories and never contain host or provider error text.
type SystemClock ¶
type SystemClock struct{}
SystemClock is the production wall clock implementation.
func (SystemClock) Now ¶
func (SystemClock) Now() time.Time
type TelemetryEvent ¶
type TelemetrySink ¶
type TelemetrySink interface {
Record(context.Context, TelemetryEvent)
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
openaicompat
Package openaicompat implements a strict OpenAI-compatible upstream adapter.
|
Package openaicompat implements a strict OpenAI-compatible upstream adapter. |
|
examples
|
|
|
basic
command
|
|
|
internal
|
|
|
protocol
|
|