Documentation
¶
Overview ¶
Package availability owns runtime state for exact provider offerings.
Index ¶
- Constants
- Variables
- func NewInstanceID() string
- type Clock
- type Config
- type KVStore
- type Offering
- type Publisher
- type Record
- type SharedConfig
- type Snapshot
- type State
- type Tracker
- func (t *Tracker) Acquire(route routing.Route) bool
- func (t *Tracker) LastPublishError() error
- func (t *Tracker) RecordFailure(route routing.Route, providerFailure *failure.Failure, _ time.Duration)
- func (t *Tracker) RecordSuccess(route routing.Route, _ time.Duration)
- func (t *Tracker) Refresh(_ context.Context)
- func (t *Tracker) Release(route routing.Route)
- func (t *Tracker) Reset(offering Offering) error
- func (t *Tracker) RunShared(ctx context.Context)
- func (t *Tracker) Snapshot() Snapshot
- func (t *Tracker) UseSharedStore(store KVStore, config SharedConfig) error
Constants ¶
const ( // its last transition. A dead replica's record expires on its own. DefaultSharedTTL = time.Minute // reads peer state at most once per interval. DefaultSharedRefreshInterval = 5 * time.Second )
Variables ¶
var ( // ErrInvalidOffering reports an incomplete offering identity. ErrInvalidOffering = errors.New("provider offering identity is incomplete") // ErrInvalidConfig reports an invalid availability policy. ErrInvalidConfig = errors.New("availability configuration is invalid") )
ErrInvalidSharedStore reports a missing distributed store.
Functions ¶
func NewInstanceID ¶ added in v1.2.0
func NewInstanceID() string
NewInstanceID returns a random replica identity for shared health records.
Types ¶
type Config ¶
Config defines the offering circuit policy.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the production availability policy.
type KVStore ¶ added in v1.2.0
type KVStore interface {
SetWithTTL(ctx context.Context, key string, value []byte, ttl time.Duration) error
ScanWithPrefix(ctx context.Context, prefix string, limit int) ([]string, error)
BatchGet(ctx context.Context, keys []string) (map[string][]byte, error)
}
KVStore is the storage subset that shared health state uses. The deployment's distributed key-value store satisfies it. A tracker without one stays process-local.
type Offering ¶
Offering identifies one provider model endpoint.
func OfferingFromRoute ¶
OfferingFromRoute converts a planned route to runtime identity.
type Record ¶
type Record struct {
Offering Offering
State State
FailureKind failure.Kind
ConsecutiveFailure int
OpenUntil time.Time
}
Record is one immutable offering state record.
type SharedConfig ¶ added in v1.2.0
type SharedConfig struct {
// random identity.
InstanceID string
TTL time.Duration
RefreshInterval time.Duration
}
SharedConfig bounds the distributed health exchange.
type State ¶
type State string
State identifies one offering's runtime availability state.
const ( // StateHealthy admits normal attempts for an offering. StateHealthy State = "healthy" // StateOpen rejects attempts until the open interval expires. StateOpen State = "open" // StateHalfOpen admits one recovery probe. StateHalfOpen State = "half_open" StateUnavailable State = "unavailable" )
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker owns all offering state transitions and half-open probe admission.
func (*Tracker) Acquire ¶
Acquire admits one attempt. A half-open offering admits one probe at a time.
func (*Tracker) LastPublishError ¶
LastPublishError returns the latest derived-projection or shared-store publication error.
func (*Tracker) RecordFailure ¶
func (t *Tracker) RecordFailure(route routing.Route, providerFailure *failure.Failure, _ time.Duration)
RecordFailure applies one normalized failure to the offering state machine.
func (*Tracker) RecordSuccess ¶
RecordSuccess closes the offering circuit and clears failure evidence.
func (*Tracker) Refresh ¶
Refresh makes expired open offerings eligible for one half-open probe and uses only process memory. The shared worker owns peer refresh.
func (*Tracker) Release ¶ added in v1.0.2
Release ends a prior half-open admission without recording a provider outcome. Credential selection uses it when no provider request ran.
func (*Tracker) Reset ¶
Reset makes one offering healthy. Catalog activation or an operator action can use it.
func (*Tracker) RunShared ¶ added in v1.3.0
RunShared exchanges advisory health until cancellation. Only one worker runs.
func (*Tracker) UseSharedStore ¶ added in v1.2.0
func (t *Tracker) UseSharedStore(store KVStore, config SharedConfig) error
UseSharedStore turns on distributed health publication. The tracker writes local observations through RunShared. Inference callbacks use memory only.