Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
func Middleware(ctrl Controller) func(http.Handler) http.Handler
Middleware returns a standard net/http middleware that disables scale-to-zero at the start of each request and re-enables it after the handler completes. Connections from loopback addresses are ignored and do not affect the scale-to-zero state.
Types ¶
type Controller ¶
type Controller interface {
// Disable turns scale-to-zero off.
Disable(ctx context.Context) error
// Enable re-enables scale-to-zero after it has previously been disabled.
Enable(ctx context.Context) error
}
func NewUnikraftCloudController ¶
func NewUnikraftCloudController() Controller
type DebouncedController ¶
type DebouncedController struct {
// contains filtered or unexported fields
}
func NewDebouncedController ¶
func NewDebouncedController(ctrl Controller) *DebouncedController
NewDebouncedController creates a DebouncedController with no re-enable cooldown.
func NewDebouncedControllerWithCooldown ¶
func NewDebouncedControllerWithCooldown(ctrl Controller, cooldown time.Duration) *DebouncedController
NewDebouncedControllerWithCooldown creates a DebouncedController that delays re-enabling scale-to-zero by the given cooldown after the last active holder releases. A new Disable call during the cooldown cancels the pending re-enable, avoiding rapid toggling from sequential requests.
func (*DebouncedController) Disable ¶
func (c *DebouncedController) Disable(ctx context.Context) error
func (*DebouncedController) Enable ¶
func (c *DebouncedController) Enable(ctx context.Context) error
type NoopController ¶
type NoopController struct{}
func NewNoopController ¶
func NewNoopController() *NoopController
type Oncer ¶
type Oncer struct {
// contains filtered or unexported fields
}
Oncer wraps a Controller and ensures that Disable and Enable are called at most once.
func NewOncer ¶
func NewOncer(c Controller) *Oncer
type PinnedController ¶
type PinnedController interface {
Controller
// Pin holds scale-to-zero disabled until Unpin is called. The pin is a
// boolean, not a counter: repeated calls are idempotent.
Pin(ctx context.Context) error
// Unpin releases the pin. If no request-driven holders remain,
// scale-to-zero is re-enabled (honoring any configured cooldown).
Unpin(ctx context.Context) error
}
PinnedController extends Controller with an out-of-band "pin" that holds scale-to-zero disabled independently of the request-driven refcount used by the HTTP middleware. While the pin is held, request-driven Enable calls do not re-enable scale-to-zero; only Unpin can release it.
This is intended for explicit lifecycle control (e.g. a control-plane API reserving a VM in a hot pool) where the holder is not tied to an inflight HTTP request.