Documentation
¶
Index ¶
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 )
Variables ¶
This section is empty.
Functions ¶
func CheckTupleSize ¶
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.
Types ¶
type BSONTotalSizeChecker ¶
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 ¶
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 ¶
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 ¶
func (c *BSONTotalSizeChecker) Outcome() error
Outcome returns the check outcome or whether an error occurred within a call to the Check method.
type Checker ¶
type Checker interface { Check(interface{}) Outcome() error }
Checker is implemented by types that can perform quota limit checks.
type MapKeyValueSizeChecker ¶
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 ¶
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 ¶
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 ¶
func (c *MapKeyValueSizeChecker) Outcome() error
Outcome returns the check outcome or whether an error occurred within a call to the Check method.
type MultiChecker ¶
type MultiChecker struct {
// contains filtered or unexported fields
}
MultiChecker composes a list of individual Checker instances.
func NewMultiChecker ¶
func NewMultiChecker(checkers ...Checker) *MultiChecker
NewMultiChecker returns a Checker that composes the Check/Outcome logic for the specified list of Checkers.
func (MultiChecker) Check ¶
func (c MultiChecker) Check(v interface{})
Check passes v to the Check method for each one of the composed Checkers.
func (MultiChecker) Outcome ¶
func (c MultiChecker) Outcome() error
Outcome invokes Outcome on each composed Checker and returns back any obtained error or nil if all checks succeeded.