quota

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const NoopName = "noop"

Variables

This section is empty.

Functions

func Register

func Register(name string, f Factory)

Register adds a Factory under the given name. Panics on duplicate — see pkg/plugins.Register for the rationale.

Types

type Factory

type Factory func(h framework.Handle, args framework.Args) (Provider, error)

Factory constructs a quota Provider from shared runtime dependencies and provider-specific parameters. Passing nil args is legal for Providers that take no parameters (e.g. Noop).

func Get

func Get(name string) (Factory, error)

Get looks up a registered Factory.

type Noop

type Noop struct{}

Noop is a Provider that reports the quota feature as disabled. It is the default for open-source builds where no quota backend is configured.

func (Noop) Enabled

func (Noop) Enabled() bool

func (Noop) ListForUser

func (Noop) ListForUser(_ context.Context, _, _ string) ([]QuotaInfo, *domain.AppError)

type Provider

type Provider interface {
	// Enabled reports whether the provider can answer queries. False means
	// the quota feature is unavailable (no backend configured, CRD missing,
	// etc.) — callers should skip quota checks gracefully.
	Enabled() bool

	// ListForUser returns all quotas visible to the (user, team) pair.
	// Returns (nil, nil) when the provider is disabled or the user has no
	// visible quotas; returns an AppError only on transient/system failures.
	ListForUser(ctx context.Context, user, team string) ([]QuotaInfo, *domain.AppError)
}

Provider exposes read-only access to quota information.

A nil Provider is not valid; callers should always hold at least a Noop. Use Enabled() to decide whether to expose quota-related UI.

func Build

func Build(name string, h framework.Handle, args framework.Args) (Provider, error)

Build looks up a Factory by name and invokes it.

func NewNoop

func NewNoop() Provider

NewNoop returns a disabled quota Provider. Safe to share.

func NoopFactory

func NoopFactory(_ framework.Handle, _ framework.Args) (Provider, error)

NoopFactory is the Factory form of NewNoop — no Handle or Args are used. Registered at package init() so callers can Build("noop", h, nil) without any extra wiring.

type QuotaInfo

type QuotaInfo = domain.QuotaInfo

QuotaInfo is re-exported from the domain package to keep callers decoupled from the service layer. When the Scitix implementation is extracted this remains the stable type.

Jump to

Keyboard shortcuts

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