regulator

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 11 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 regulator supplies measured process signals for the decision engine. Providers sample in the background, never during request admission.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Goroutines

type Goroutines struct{}

func (Goroutines) Sample

type Memory

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

func NewMemory

func NewMemory(c MemoryConfig) (*Memory, error)

NewMemory compares Go-managed memory against an explicit budget (or the current finite GOMEMLIMIT) and, on Linux, visible finite cgroup limits. The highest measured ratio wins. No host-RAM fallback is guessed. Go-managed bytes are runtime Sys - HeapReleased, not process RSS or native allocations.

func (*Memory) Sample

func (m *Memory) Sample(ctx context.Context) (decision.Observation, error)

func (*Memory) Snapshot

func (m *Memory) Snapshot() MemoryState

type MemoryConfig

type MemoryConfig struct{ LimitBytes int64 }

type MemoryState

type MemoryState struct {
	Source                string
	UsedBytes, LimitBytes uint64
	Ratio                 float64
	ObservedAt            time.Time
}

type SQLPool added in v0.8.0

type SQLPool struct{ DB *sql.DB }

SQLPool reports current connection utilization, not availability or queue length. The pool must have a finite MaxOpenConns; Stats makes no SQL calls.

func (SQLPool) Sample added in v0.8.0

func (p SQLPool) Sample(ctx context.Context) (decision.Observation, error)

type SQLPoolContention added in v0.8.1

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

SQLPoolContention reports 0 or 1. Unlike SQLPool, occupancy alone does not establish pressure. A new DBStats.WaitCount increment activates pressure; recovery requires a quiet interval and a pool that is no longer full. It is not queue depth, an availability check, or a guarantee of fair scheduling. Use one provider per pool/collection stream and a decision threshold of 1. Historical waits before construction are ignored. LastWaitAt is the sample time detecting new waits, not a database-provided event timestamp. Construct with NewSQLPoolContention; the zero value is not usable.

func NewSQLPoolContention added in v0.8.1

func NewSQLPoolContention(c SQLPoolContentionConfig) (*SQLPoolContention, error)

func (*SQLPoolContention) Sample added in v0.8.1

func (*SQLPoolContention) Snapshot added in v0.8.1

type SQLPoolContentionConfig added in v0.8.1

type SQLPoolContentionConfig struct {
	DB            *sql.DB
	RecoveryQuiet time.Duration
}

SQLPoolContentionConfig configures a local, sampled pool-wait signal. The application owns DB. RecoveryQuiet defaults to 200ms; values must be positive.

type SQLPoolContentionState added in v0.8.1

type SQLPoolContentionState struct {
	Pressure               bool
	Utilization            float64
	WaitCountDelta         int64
	LastWaitAt, ObservedAt time.Time
	Reason                 string
}

Jump to

Keyboard shortcuts

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