juju: github.com/wallyworld/juju/core/quota Index | Files

package quota

import "github.com/wallyworld/juju/core/quota"

Index

Package Files

bson.go fixed_limits.go kv.go multichecker.go

Constants

const (
    // MaxCharmStateKeySize describes the max allowed key length for each
    // entry that a charm attempts to persist to the controller.
    MaxCharmStateKeySize = 256

    // MaxCharmStateValueSize describes the max allowed value length for
    // each entry that a charm attempts to persist to the controller.
    MaxCharmStateValueSize = 64 * 1024
)

func CheckTupleSize Uses

func CheckTupleSize(key, value interface{}, maxKeyLen, maxValueLen int) error

CheckTupleSize checks whether the length of the provided key-value pair is within the provided limits. If the key or value is a string, then its length will be used for comparison purposes. Otherwise, the effective length is calculated by serializing to BSON and counting the length of the serialized data.

Any of the max values can be set to zero to bypass the size check.

type BSONTotalSizeChecker Uses

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

BSONTotalSizeChecker can be used to verify that the total bson-encoded size of one or more items does not exceed a particular limit.

func NewBSONTotalSizeChecker Uses

func NewBSONTotalSizeChecker(maxSize int) *BSONTotalSizeChecker

NewBSONTotalSizeChecker returns a BSONTotalSizeChecker instance with the specified maxSize limit. The maxSize parameter may also be set to zero to disable quota checks.

func (*BSONTotalSizeChecker) Check Uses

func (c *BSONTotalSizeChecker) Check(v interface{})

Check adds the serialized size of v to the current tally and updates the checker's error state.

func (*BSONTotalSizeChecker) Outcome Uses

func (c *BSONTotalSizeChecker) Outcome() error

Outcome returns the check outcome or whether an error occurred within a call to the Check method.

type Checker Uses

type Checker interface {
    Check(interface{})
    Outcome() error
}

Checker is implemented by types that can perform quota limit checks.

type MapKeyValueSizeChecker Uses

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

A MapKeyValueSizeChecker can be used to verify that none of the keys and values in a map exceed a particular limit.

func NewMapKeyValueSizeChecker Uses

func NewMapKeyValueSizeChecker(maxKeySize, maxValueSize int) *MapKeyValueSizeChecker

NewMapKeyValueSizeChecker returns a new MapKeyValueSizeChecker instance that limits map keys to maxKeySize and map values to maxValueSize. Any of the max values may also set to 0 to disable quota checks.

func (*MapKeyValueSizeChecker) Check Uses

func (c *MapKeyValueSizeChecker) Check(v interface{})

Check applies the configured size checks to v and updates the checker's internal state. Check expects a map as an argument where both the keys and the values can be serialized to BSON; any other value will cause an error to be returned when Outcome is called.

func (*MapKeyValueSizeChecker) Outcome Uses

func (c *MapKeyValueSizeChecker) Outcome() error

Outcome returns the check outcome or whether an error occurred within a call to the Check method.

type MultiChecker Uses

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

MultiChecker composes a list of individual Checker instances.

func NewMultiChecker Uses

func NewMultiChecker(checkers ...Checker) *MultiChecker

NewMultiChecker returns a Checker that composes the Check/Outcome logic for the specified list of Checkers.

func (MultiChecker) Check Uses

func (c MultiChecker) Check(v interface{})

Check passes v to the Check method for each one of the composed Checkers.

func (MultiChecker) Outcome Uses

func (c MultiChecker) Outcome() error

Outcome invokes Outcome on each composed Checker and returns back any obtained error or nil if all checks succeeded.

Package quota imports 3 packages (graph). Updated 2020-07-21. Refresh now. Tools for package owners.