Help us shape the future of Go! Take the 2026 Go Developer Survey

proxy

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package proxy admits candidate work and budgets shared memory for every protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Budget

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

Budget caps buffered memory shared across every in-flight request. Reservations never block, so a full budget fails immediately.

func NewBudget

func NewBudget(limit int) *Budget

NewBudget returns a budget that allows at most limit reserved bytes.

func (*Budget) Limit

func (b *Budget) Limit() int

Limit reports the total number of bytes the budget allows.

func (*Budget) Release

func (b *Budget) Release(size int)

Release returns size previously reserved bytes to the budget. Releasing more than is reserved panics.

func (*Budget) Reserve

func (b *Budget) Reserve(size int) (reserved bool)

Reserve claims size bytes and reports whether they fit in the remaining budget.

type CandidateRun

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

CandidateRun is one admitted unit of candidate work. Its pointer gives the non-comparable cancellation function a stable map identity.

type Candidates

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

Candidates admits candidate work and tracks it so quarantine and shutdown can cancel everything in flight. Quarantine lasts for the process lifetime.

func NewCandidates

func NewCandidates(config CandidatesConfig) *Candidates

NewCandidates tracks candidate work, quarantining beyond the configured concurrent runs.

func (*Candidates) Close added in v0.15.0

func (c *Candidates) Close()

Close refuses further candidate work and cancels active runs without waiting.

func (*Candidates) Finish

func (c *Candidates) Finish(run *CandidateRun)

Finish releases an admitted run once all of its work has stopped.

func (*Candidates) Quarantine

func (c *Candidates) Quarantine(ctx context.Context, reason model.QuarantineReason)

Quarantine refuses all further candidate work and cancels active runs. Only the first reason is kept.

func (*Candidates) QuarantineStatus added in v0.30.0

func (c *Candidates) QuarantineStatus() Option[model.Quarantine]

QuarantineStatus reports the quarantine in effect, if any.

func (*Candidates) Quarantined added in v0.39.0

func (c *Candidates) Quarantined() <-chan model.Quarantine

Quarantined returns a channel that receives the quarantine once, when it begins. Only one receiver gets it, so it has a single consumer.

func (*Candidates) Shutdown

func (c *Candidates) Shutdown(ctx context.Context) error

Shutdown refuses further candidate work and waits for active runs to finish.

func (*Candidates) Start

func (c *Candidates) Start(ctx context.Context, cancel context.CancelFunc) Option[*CandidateRun]

Start admits candidate work that cancel stops, returning None when it is refused. Exceeding the concurrency limit quarantines the candidate.

type CandidatesConfig added in v0.25.0

type CandidatesConfig struct {
	// CandidateMaxInFlight limits concurrent candidate requests.
	CandidateMaxInFlight int `default:"64" help:"Maximum concurrent candidate requests before quarantine."`
}

CandidatesConfig contains the command-line configuration for candidate admission.

func (CandidatesConfig) Validate added in v0.25.0

func (c CandidatesConfig) Validate() error

Validate checks that candidates can be admitted.

Jump to

Keyboard shortcuts

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