Documentation ¶
Index ¶
- Constants
- Variables
- func Driver(ctx context.Context, reference string) (driver.Driver, error)
- func IgnoreLimitation(ignoreLimitation bool) func(*Options)
- func ReferenceID(i interface{}) string
- func RefreshForProjects(ctx context.Context) error
- func Validate(ctx context.Context, reference string, hardLimits types.ResourceList) error
- func WithReferenceObject() func(*Options)
- type Controller
- type Option
- type Options
Constants ¶
View Source
const (
// ProjectReference reference type for project
ProjectReference = "project"
)
Variables ¶
View Source
var ( // Ctl is a global quota controller instance Ctl = NewController() )
Functions ¶
func IgnoreLimitation ¶
IgnoreLimitation set IgnoreLimitation for the Options
func ReferenceID ¶
func ReferenceID(i interface{}) string
ReferenceID returns reference id for the interface
func RefreshForProjects ¶
RefreshForProjects refresh quotas of all projects
func WithReferenceObject ¶
func WithReferenceObject() func(*Options)
WithReferenceObject set WithReferenceObject to true for the Options
Types ¶
type Controller ¶
type Controller interface { // Count returns the total count of quotas according to the query. Count(ctx context.Context, query *q.Query) (int64, error) // Create ensure quota for the reference object Create(ctx context.Context, reference, referenceID string, hardLimits types.ResourceList, used ...types.ResourceList) (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, options ...Option) (*quota.Quota, error) // GetByRef returns quota by reference object GetByRef(ctx context.Context, reference, referenceID string, options ...Option) (*quota.Quota, error) // IsEnabled returns true when quota enabled for reference object IsEnabled(ctx context.Context, reference, referenceID string) (bool, error) // List list quotas List(ctx context.Context, query *q.Query, options ...Option) ([]*quota.Quota, error) // Refresh refresh quota for the reference object Refresh(ctx context.Context, reference, referenceID string, options ...Option) error // Request request resources to run f // Before run the function, it reserves the resources, // then runs f and refresh quota when f success, // in the finally it releases the resources which reserved at the beginning. Request(ctx context.Context, reference, referenceID string, resources types.ResourceList, f func() error) error // Update update quota Update(ctx context.Context, q *quota.Quota) error }
Controller defines the operations related with quotas
func NewController ¶
func NewController() Controller
NewController creates an instance of the default quota controller
Click to show internal directories.
Click to hide internal directories.