quotas

package
v0.0.0-...-194264a Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Quotas

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

Quotas provides a quota and limit service

func (*Quotas) Consume

func (qs *Quotas) Consume(tenantID string, resources ...payloads.RequestedResource) chan Result

Consume will update the quota records to indicate that the tenant is using all the resources specified. This method should usually be used on a per-instance/volume/image basis as it will also check against the limits. The exception to this is for initial import when disregarding the result.

This method returns a Result channel indicating whether the consumption is allowed. The result of the Consume() is indicated by Result.Allowed(). The caller can choose to ignore this or reclaim the resources used (e.g. by terminating an instance.) If the caller chooses to reclaim the resource they must call Quotas.Release(). The resources used in the original request are available in the result by calling Result.Resources(). If Result.Allowed() returns false then then Result.Reason() returns an explanation that can be shared with the user.

func (*Quotas) DeleteTenant

func (qs *Quotas) DeleteTenant(tenantID string)

DeleteTenant will delete the givent tenant from the quota service

func (*Quotas) DumpQuotas

func (qs *Quotas) DumpQuotas(tenantID string) []types.QuotaDetails

DumpQuotas provides the list of quotas and limits along with usage for a given tenant

func (*Quotas) Init

func (qs *Quotas) Init()

Init is used to initialise the quota service.

func (*Quotas) Release

func (qs *Quotas) Release(tenantID string, resources ...payloads.RequestedResource)

Release will update the quota records for a tenant to indicate that it is no longer using the supplied resources.

func (*Quotas) Shutdown

func (qs *Quotas) Shutdown()

Shutdown will stop the quota service and should be called when it is no longer needed.

func (*Quotas) Update

func (qs *Quotas) Update(tenantID string, quotas []types.QuotaDetails)

Update will populate the quota service with quota and limits information.

type Result

type Result interface {
	Allowed() bool
	Reason() string
	Resources() []payloads.RequestedResource
}

Result provides a method for querying the result of a Consume operation.

Jump to

Keyboard shortcuts

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