quota

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 12 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 quota enforces per-project quotas at admission and meters usage (§7.2).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limits

type Limits struct {
	CPU              float64 `json:"cpu,omitempty"`       // cores reserved by desired tasks
	MemoryMiB        int     `json:"memoryMiB,omitempty"` // MiB reserved by desired tasks
	Tasks            int     `json:"tasks,omitempty"`     // desired tasks
	Services         int     `json:"services,omitempty"`
	Jobs             int     `json:"jobs,omitempty"`
	Domains          int     `json:"domains,omitempty"` // custom domains
	ConcurrentBuilds int     `json:"concurrentBuilds,omitempty"`
	LogsMiBPerDay    int     `json:"logsMiBPerDay,omitempty"` // metered and warned, not enforced
}

Limits of a project or environment. Zero means unlimited.

func (Limits) Validate

func (l Limits) Validate() error

Validate rejects negative limits.

type Manager

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

func New

func New(st *store.Store, wl *workload.Manager, m *metrics.Store, log *slog.Logger) *Manager

func (*Manager) AddLogBytes

func (m *Manager) AddLogBytes(project, env string, n int)

AddLogBytes counts ingested log volume (called by the log store).

func (*Manager) Admit

func (m *Manager) Admit(ctx context.Context, req workload.AdmitRequest) error

Admit checks a service change (workload.Manager.Admit).

func (*Manager) AdmitCount

func (m *Manager) AdmitCount(ctx context.Context, envID, what string) error

AdmitCount checks adding one job or domain to an environment.

func (*Manager) BuildSlots

func (m *Manager) BuildSlots(ctx context.Context, serviceID string) (projectID string, limit int)

BuildSlots tells the build queue how many builds a service's project may run at once (0: no limit).

func (*Manager) LimitsFor

func (m *Manager) LimitsFor(ctx context.Context, projectID, envID string) (project, env Limits, err error)

LimitsFor returns a project's limits and an environment's override.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run meters usage every minute until ctx ends.

func (*Manager) UsageOf

func (m *Manager) UsageOf(ctx context.Context, projectID, envID string) (Usage, error)

UsageOf sums a project's (or, with envID, an environment's) usage.

type Usage

type Usage struct {
	CPU          float64 `json:"cpu"`
	MemoryMiB    int     `json:"memoryMiB"`
	Tasks        int     `json:"tasks"`
	Services     int     `json:"services"`
	Jobs         int     `json:"jobs"`
	Domains      int     `json:"domains"`
	Builds       int     `json:"builds"` // building now
	LogsMiBToday float64 `json:"logsMiBToday"`
}

Usage is what a project or environment holds now.

Jump to

Keyboard shortcuts

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