Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Rebalancer ¶ added in v0.79.0
type Rebalancer struct {
// contains filtered or unexported fields
}
Rebalancer consumes core.Diagnosis and moves workers between stages. Moves at most one worker per interval. Reverts if throughput regresses.
func NewRebalancer ¶ added in v0.79.0
func NewRebalancer(diagnosis func() *core.Diagnosis, opts ...RebalancerOption) *Rebalancer
NewRebalancer creates a rebalancer that consumes diagnosis snapshots. The diagnosis function returns the latest core.Diagnosis, or nil if no diagnosis is available yet.
func (*Rebalancer) AddStage ¶ added in v0.79.0
func (r *Rebalancer) AddStage(sc StageControl)
AddStage registers a stage for rebalancing. Must be called before Run.
func (*Rebalancer) Disable ¶ added in v0.79.0
func (r *Rebalancer) Disable()
Disable stops actuation. Workers stay where they are.
func (*Rebalancer) Enable ¶ added in v0.79.0
func (r *Rebalancer) Enable()
Enable resumes actuation.
func (*Rebalancer) Enabled ¶ added in v0.79.0
func (r *Rebalancer) Enabled() bool
Enabled returns whether the rebalancer is currently actuating.
func (*Rebalancer) FormatStatus ¶ added in v0.79.0
func (r *Rebalancer) FormatStatus() string
FormatStatus returns a human-readable status line.
type RebalancerOption ¶ added in v0.79.0
type RebalancerOption func(*Rebalancer)
RebalancerOption configures a Rebalancer.
func WithCooldown ¶ added in v0.79.0
func WithCooldown(n int) RebalancerOption
WithCooldown sets the number of intervals to wait after a move.
func WithKillSwitch ¶ added in v0.79.0
func WithKillSwitch(fn func() bool) RebalancerOption
WithKillSwitch sets a function that, when returning true, disables actuation.
func WithRebalancerLogger ¶ added in v0.79.0
func WithRebalancerLogger(l *log.Logger) RebalancerOption
WithRebalancerLogger sets the logger.
type StageControl ¶ added in v0.79.0
type StageControl struct {
Name string
SetWorkers func(int) (int, error)
Stats func() toc.Stats
Policy WorkerPolicy
}
StageControl provides actuation and observation for a stage.
type WorkerPolicy ¶ added in v0.79.0
type WorkerPolicy struct {
Min int // minimum workers (default 1)
Max int // maximum workers (0 = unlimited)
DonateOK bool // can workers be taken from this stage
ReceiveOK bool // can workers be added to this stage
}
WorkerPolicy constrains how the rebalancer treats a stage.