Help us shape the future of Go! Take the 2026 Go Developer Survey

scheduler

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Credential

type Credential = model.Credential

type CredentialScheduler

type CredentialScheduler interface {
	// Pick selects the best available credential matching the given filter.
	// tried is an optional set of credential IDs that have already been attempted.
	Pick(ctx context.Context, filter Filter, tried map[string]struct{}) (*ManagedCredential, error)

	// MarkResult updates credential availability state from a request result.
	MarkResult(ctx context.Context, result Result)

	// SetSelector replaces the active credential selector.
	SetSelector(s CredentialSelector)

	// SetQuotaCooldownDisabled disables quota cooldown handling when true.
	SetQuotaCooldownDisabled(disable bool)

	// RegisterCredential adds a new credential to the scheduler.
	RegisterCredential(cred *ManagedCredential)

	// UpdateCredential synchronizes updated credential state into the scheduler.
	UpdateCredential(cred *ManagedCredential)

	// DeregisterCredential removes a credential from the scheduler.
	DeregisterCredential(id string)

	// Rebuild recreates the complete scheduler state from a credential snapshot.
	Rebuild(creds []*ManagedCredential)
}

CredentialScheduler manages an in-memory set of credentials and selects the best available one for each request.

func NewScheduler

func NewScheduler(selector CredentialSelector) CredentialScheduler

NewScheduler constructs a CredentialScheduler with the given credential selector. If selector is nil, RoundRobinSelector is used.

type CredentialSelector

type CredentialSelector interface {
	PickFromBucket(bucket *ReadyBucket, predicate func(*ManagedCredential) bool) *ManagedCredential
}

CredentialSelector picks a credential from a pre-filtered, priority-sorted ReadyBucket. Implement this interface to provide a custom selection algorithm.

type Error

type Error = model.Error

type FillFirstSelector

type FillFirstSelector struct{}

FillFirstSelector exhausts one credential before moving to the next, useful for staggering rolling-window subscription caps.

func (*FillFirstSelector) PickFromBucket

func (s *FillFirstSelector) PickFromBucket(bucket *ReadyBucket, predicate func(*ManagedCredential) bool) *ManagedCredential

PickFromBucket picks the first matching credential in the bucket.

type Filter

type Filter struct {
	Type            string
	CredentialScope string
	Model           string
	Selector        string
}

type ManagedCredential

type ManagedCredential = model.ManagedCredential

type ModelState

type ModelState = model.ModelState

type PredicateCredentialFunc

type PredicateCredentialFunc func(cred *ManagedCredential) bool

type QuotaState

type QuotaState = model.QuotaState

type ReadyBucket

type ReadyBucket struct {
	// contains filtered or unexported fields
}

ReadyBucket holds credentials at one priority level that are ready for selection.

type Result

type Result struct {
	CredentialID   string
	Model          string
	Success        bool
	RetryAfter     *time.Duration
	Error          *Error
	CredentialWide bool
}

type RoundRobinSelector

type RoundRobinSelector struct{}

RoundRobinSelector distributes requests evenly across available credentials.

func (*RoundRobinSelector) PickFromBucket

func (s *RoundRobinSelector) PickFromBucket(bucket *ReadyBucket, predicate func(*ManagedCredential) bool) *ManagedCredential

PickFromBucket picks the next credential using round-robin within the bucket.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL