tenancy

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tenancy provides bounded, process-local tenant concurrency accounting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidID

func ValidID(id string) bool

ValidID bounds hash input and rejects whitespace, control bytes and combined headers.

Types

type Config

type Config struct {
	Sharing                       *Sharing
	Limit, MaxTracked             int
	IdleTTL                       time.Duration
	MissingShared, OverflowShared bool
	Limits                        map[string]int
}

type Lease

type Lease struct {
	// contains filtered or unexported fields
}

func (*Lease) Allocation added in v0.5.0

func (t *Lease) Allocation() string

func (*Lease) Ceiling added in v0.5.0

func (t *Lease) Ceiling() int

func (*Lease) Rejected added in v0.5.0

func (t *Lease) Rejected(decision admission.Decision, now time.Time)

Rejected pauses lending after a below-share attempt hits an execution bound. Cohort/identity rejections do not create reclaim demand. No executing work is revoked.

func (*Lease) Release

func (t *Lease) Release(now time.Time)

Release is idempotent. Active entries never expire or get evicted.

func (*Lease) Retain

func (t *Lease) Retain()

Retain records successful service admission. Unused reservations are discarded.

func (*Lease) Share added in v0.5.0

func (t *Lease) Share() int

type Limiter

type Limiter struct {
	// contains filtered or unexported fields
}

func New

func New(c Config) *Limiter

func (*Limiter) Acquire

func (l *Limiter) Acquire(id string, now time.Time) (*Lease, admission.Decision)

func (*Limiter) AcquireWithLimit added in v0.5.0

func (l *Limiter) AcquireWithLimit(id string, now time.Time, capacity int) (*Lease, admission.Decision)

func (*Limiter) SharingEnabled added in v0.5.0

func (l *Limiter) SharingEnabled() bool

func (*Limiter) Snapshot

func (l *Limiter) Snapshot(now time.Time) State

type Sharing added in v0.5.0

type Sharing struct {
	Capacity, MaxConcurrent int
	Limits                  map[string]int
	DemandTTL               time.Duration
}

Sharing is validated by the public middleware constructor. Shares use the existing default Limit and per-identity overrides. Only identified tenants borrow.

type State

type State struct {
	SharingEnabled, BorrowingPaused                                             bool
	Demanding, BorrowedActive                                                   int
	DemandShares                                                                int64
	Limit, MaxTracked, Tracked, IdentifiedActive, MissingActive, OverflowActive int
	Expired                                                                     uint64
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL