Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Rebalancer ¶
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 ¶
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 ¶
func (r *Rebalancer) AddStage(sc StageControl)
AddStage registers a stage for rebalancing. Must be called before Run.
func (*Rebalancer) Disable ¶
func (r *Rebalancer) Disable()
Disable stops actuation. Workers stay where they are.
func (*Rebalancer) Enabled ¶
func (r *Rebalancer) Enabled() bool
Enabled returns whether the rebalancer is currently actuating.
func (*Rebalancer) FormatStatus ¶
func (r *Rebalancer) FormatStatus() string
FormatStatus returns a human-readable status line.
type RebalancerOption ¶
type RebalancerOption func(*Rebalancer)
RebalancerOption configures a Rebalancer.
func WithCooldown ¶
func WithCooldown(n int) RebalancerOption
WithCooldown sets the number of intervals to wait after a move.
func WithKillSwitch ¶
func WithKillSwitch(fn func() bool) RebalancerOption
WithKillSwitch sets a function that, when returning true, disables actuation.
func WithRebalancerLogger ¶
func WithRebalancerLogger(l *log.Logger) RebalancerOption
WithRebalancerLogger sets the logger.
type StageControl ¶
type StageControl struct {
Name string
SetWorkers func(int) (int, error)
Stats func() toc.Stats
Policy WorkerPolicy
}
StageControl provides actuation and observation for a stage.