policy

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 8 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Allows

func Allows(v config.VirtualKey, model string) bool

Types

type Auth

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

Auth owns key verification plus per-key request metering: RPM token buckets, a deferred-commit TPM bucket, in-flight concurrency slots, and a rolling daily USD budget. Meter state survives snapshot adoption. Sharded 16-way for ~10ns key pick at 5k RPS (Bifrost-style).

func New

func New(s *config.Snapshot) *Auth

func (*Auth) Adopt

func (a *Auth) Adopt(s *config.Snapshot)

func (*Auth) Authenticate

func (a *Auth) Authenticate(r *http.Request) (config.VirtualKey, bool)

func (*Auth) Begin

func (a *Auth) Begin(vk config.VirtualKey) BeginResult

func (*Auth) Finalize

func (a *Auth) Finalize(vk config.VirtualKey, tokens int64, costUSD float64, committed bool)

type BeginResult

type BeginResult struct {
	Allowed                bool
	Reason                 string
	RPMRemaining           int
	TPMRemaining           int
	ConcurrencyRemaining   int
	BudgetUSD              float64
	BudgetRemainingUSD     float64
	TeamBudgetUSD          float64
	TeamBudgetRemainingUSD float64
}

type Bucket

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

Jump to

Keyboard shortcuts

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