admission

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 1 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 admission provides process-local concurrency admission without a waiting queue.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decision

type Decision string
const (
	Admitted                 Decision = ""
	ConcurrencyLimit         Decision = "concurrency_limit"
	CriticalCapacityReserved Decision = "critical_capacity_reserved"
	InvalidPriority          Decision = "invalid_priority"
)

type Limiter

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

Limiter makes total and background accounting one atomic decision under a short lock. Background work cannot occupy the critical reservation, even when idle. Critical work can use all available capacity. There is no preemption.

func New

func New(limit, reserved int) *Limiter

func (*Limiter) Release

func (l *Limiter) Release(priority Priority)

func (*Limiter) SetLimit

func (l *Limiter) SetLimit(limit int)

SetLimit affects future admissions only. Existing work drains normally.

func (*Limiter) Snapshot

func (l *Limiter) Snapshot() State

func (*Limiter) TryAcquire

func (l *Limiter) TryAcquire(priority Priority) Decision

TryAcquire never waits for capacity. Admitted work requires one matching Release.

type Priority

type Priority string
const (
	Critical   Priority = "critical"
	Background Priority = "background"
)

type State

type State struct{ Limit, ReservedCritical, Active, Background int }

Jump to

Keyboard shortcuts

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