quota

package
v0.0.0-...-a548ab7 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Mgr default quota manager
	Mgr = NewManager()
)

Functions

func IsSafe

func IsSafe(hardLimits types.ResourceList, currentUsed types.ResourceList, newUsed types.ResourceList, ignoreLimitation bool) error

IsSafe check new used is safe under the hard limits

func NewResourceNotFoundError

func NewResourceNotFoundError(resource types.ResourceName) error

NewResourceNotFoundError ...

func NewResourceOverflowError

func NewResourceOverflowError(resource types.ResourceName, hardLimit, currentUsed, newUsed int64) error

NewResourceOverflowError ...

func PrettyPrintResourceNames

func PrettyPrintResourceNames(a []types.ResourceName) string

PrettyPrintResourceNames make resource names pretty

Types

type Errors

type Errors []error

Errors contains all happened errors

func (Errors) Add

func (errs Errors) Add(newErrors ...error) Errors

Add adds an error to a given slice of errors

func (Errors) Error

func (errs Errors) Error() string

Error takes a slice of all errors that have occurred and returns it as a formatted string

func (Errors) Exceeded

func (errs Errors) Exceeded() error

Exceeded returns exceeded errors from errs

func (Errors) GetErrors

func (errs Errors) GetErrors() []error

GetErrors gets all errors that have occurred and returns a slice of errors (Error type)

type Manager

type Manager interface {
	// Create create quota for the reference object
	Create(ctx context.Context, reference, referenceID string, hardLimits types.ResourceList, usages ...types.ResourceList) (int64, error)

	// Count returns the total count of quotas according to the query.
	Count(ctx context.Context, query *q.Query) (int64, error)

	// Delete delete quota by id
	Delete(ctx context.Context, id int64) error

	// Get returns quota by id
	Get(ctx context.Context, id int64) (*Quota, error)

	// GetByRef returns quota by reference object
	GetByRef(ctx context.Context, reference, referenceID string) (*Quota, error)

	// Update update quota
	Update(ctx context.Context, quota *Quota) error

	// List list quotas
	List(ctx context.Context, query *q.Query) ([]*Quota, error)
}

Manager interface provide the management functions for quotas

func NewManager

func NewManager() Manager

NewManager returns quota manager

type Quota

type Quota = models.Quota

Quota alias `models.Quota` to make it natural to use the Manager

type ResourceNotFound

type ResourceNotFound struct {
	Resource types.ResourceName
}

ResourceNotFound ...

func (*ResourceNotFound) Error

func (e *ResourceNotFound) Error() string

type ResourceOverflow

type ResourceOverflow struct {
	Resource    types.ResourceName
	HardLimit   int64
	CurrentUsed int64
	NewUsed     int64
}

ResourceOverflow ...

func (*ResourceOverflow) Error

func (e *ResourceOverflow) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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