Documentation ¶
Index ¶
- type Quotas
- func (qs *Quotas) Consume(tenantID string, resources ...payloads.RequestedResource) chan Result
- func (qs *Quotas) DumpQuotas(tenantID string) []types.QuotaDetails
- func (qs *Quotas) Init()
- func (qs *Quotas) Release(tenantID string, resources ...payloads.RequestedResource)
- func (qs *Quotas) Shutdown()
- func (qs *Quotas) Update(tenantID string, quotas []types.QuotaDetails)
- type Result
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) 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) 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.