Documentation
¶
Overview ¶
Package sleep decides when an idle deployment should be stopped. How a deployment shows activity is an Activity; the controller takes the most recent activity any of them reports, so signals can be added or replaced without touching the decision.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Activity ¶
type Activity interface {
LastActive(ctx context.Context, deployment string, now time.Time) (time.Time, error)
}
Activity reports the last time a deployment was seen doing work. A zero time means this signal has no evidence either way.
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController(now time.Time, activities ...Activity) *Controller
NewController starts the idle clock for every deployment at now, so a restarted agent never puts deployments to sleep on its first pass.
func (*Controller) AwakeSince ¶
func (c *Controller) AwakeSince(name string) time.Time
AwakeSince returns when the deployment was last noted awake, or zero.
type NetworkActivity ¶
type NetworkActivity struct {
ReceivedBytes func(ctx context.Context, deployment string) (uint64, error)
Threshold uint64
// contains filtered or unexported fields
}
NetworkActivity treats a rise in a deployment's received bytes between two observations as activity. Threshold absorbs background chatter such as DNS and health probes.