Documentation
¶
Index ¶
Constants ¶
const MaxPoolSize = 20
MaxPoolSize is the default upper bound on sandboxes per pool, applied by strategies that have no inherent cap of their own (notably AutoStrategy). It exists to prevent runaway growth from buggy scaling logic.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutoStrategy ¶
type AutoStrategy struct {
// contains filtered or unexported fields
}
AutoStrategy implements auto-scaling with slot-based capacity
func (*AutoStrategy) InitializeTracker ¶
func (s *AutoStrategy) InitializeTracker() *ConcurrencyTracker
func (*AutoStrategy) LeaseSize ¶
func (s *AutoStrategy) LeaseSize() int
func (*AutoStrategy) MaxInstances ¶ added in v0.9.0
func (s *AutoStrategy) MaxInstances() int
func (*AutoStrategy) MinInstances ¶ added in v0.9.0
func (s *AutoStrategy) MinInstances() int
func (*AutoStrategy) ScaleDownDelay ¶
func (s *AutoStrategy) ScaleDownDelay() time.Duration
type ConcurrencyStrategy ¶
type ConcurrencyStrategy interface {
// InitializeTracker creates a new tracker for a sandbox
InitializeTracker() *ConcurrencyTracker
// LeaseSize returns how much capacity to allocate per lease (for two-tier leasing)
LeaseSize() int
// ScaleDownDelay returns how long to wait before retiring idle sandbox
ScaleDownDelay() time.Duration
// MinInstances returns the strategy-enforced floor on Pool.DesiredInstances:
// the sandboxpool manager will not scale the pool below this count.
// 0 allows the pool to scale to zero when idle.
MinInstances() int
// MaxInstances returns the maximum sandbox count the pool may scale to.
// Strategies without an inherent cap return MaxPoolSize.
MaxInstances() int
// contains filtered or unexported methods
}
ConcurrencyStrategy encapsulates mode-specific capacity management logic. Implementations of this interface are package-internal only - the lowercase methods (checkCapacity, releaseCapacity) enforce implementation locality.
func NewStrategy ¶
func NewStrategy(svc *core_v1alpha.ServiceConcurrency) ConcurrencyStrategy
NewStrategy creates a strategy from ServiceConcurrency config
func NewStrategyForVersion ¶ added in v0.9.0
func NewStrategyForVersion(ver *core_v1alpha.AppVersion, service string, svc *core_v1alpha.ServiceConcurrency) ConcurrencyStrategy
NewStrategyForVersion returns the concurrency strategy for a request targeting (ver, service). Ephemeral routing semantics apply only to the user-facing "web" service: that service gets EphemeralStrategy (capped at a single sandbox, scale-to-zero on idle), while supporting services on the same ephemeral version (databases, workers, etc.) honor their configured ServiceConcurrency like a normal deploy.
type ConcurrencyTracker ¶
type ConcurrencyTracker struct {
// contains filtered or unexported fields
}
ConcurrencyTracker manages capacity state for a single sandbox
func (*ConcurrencyTracker) AcquireLease ¶
func (t *ConcurrencyTracker) AcquireLease() int
AcquireLease allocates capacity and returns the lease size. Caller must check HasCapacity() before calling this method.
func (*ConcurrencyTracker) HasCapacity ¶
func (t *ConcurrencyTracker) HasCapacity() bool
func (*ConcurrencyTracker) Max ¶
func (t *ConcurrencyTracker) Max() int
func (*ConcurrencyTracker) ReleaseLease ¶
func (t *ConcurrencyTracker) ReleaseLease(size int)
func (*ConcurrencyTracker) Used ¶
func (t *ConcurrencyTracker) Used() int
type EphemeralStrategy ¶ added in v0.9.0
type EphemeralStrategy struct {
// contains filtered or unexported fields
}
EphemeralStrategy implements scale-to-zero capped at 1 instance, for ephemeral preview deploys. Capacity tracking matches FixedStrategy (always accepts leases) since there is no scaling alternative for an overloaded preview sandbox: just route everything at the one instance. When the sole sandbox sits idle past ScaleDownDelay, the pool scales to zero and the next request cold-starts a fresh one.
func (*EphemeralStrategy) InitializeTracker ¶ added in v0.9.0
func (s *EphemeralStrategy) InitializeTracker() *ConcurrencyTracker
func (*EphemeralStrategy) LeaseSize ¶ added in v0.9.0
func (s *EphemeralStrategy) LeaseSize() int
func (*EphemeralStrategy) MaxInstances ¶ added in v0.9.0
func (s *EphemeralStrategy) MaxInstances() int
func (*EphemeralStrategy) MinInstances ¶ added in v0.9.0
func (s *EphemeralStrategy) MinInstances() int
func (*EphemeralStrategy) ScaleDownDelay ¶ added in v0.9.0
func (s *EphemeralStrategy) ScaleDownDelay() time.Duration
type FixedStrategy ¶
type FixedStrategy struct {
// contains filtered or unexported fields
}
FixedStrategy implements fixed instance count (no slot-based capacity)
func (*FixedStrategy) InitializeTracker ¶
func (s *FixedStrategy) InitializeTracker() *ConcurrencyTracker
func (*FixedStrategy) LeaseSize ¶
func (s *FixedStrategy) LeaseSize() int
func (*FixedStrategy) MaxInstances ¶ added in v0.9.0
func (s *FixedStrategy) MaxInstances() int
func (*FixedStrategy) MinInstances ¶ added in v0.9.0
func (s *FixedStrategy) MinInstances() int
func (*FixedStrategy) ScaleDownDelay ¶
func (s *FixedStrategy) ScaleDownDelay() time.Duration