Documentation
¶
Overview ¶
Package limits contains paths to enforce read query limits.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsQueryLimitExceededError ¶ added in v1.0.1
IsQueryLimitExceededError returns true if the error is a query limits exceeded error.
func NewQueryLimitExceededError ¶ added in v1.0.1
NewQueryLimitExceededError creates a query limit exceeded error.
Types ¶
type Key ¶ added in v1.0.1
type Key string
Key is a specific string type for context setting.
const SourceContextKey Key = "source"
SourceContextKey is the key for setting and retrieving source from context.
type LookbackLimit ¶
type LookbackLimit interface {
// Inc increments the recent value for the limit.
Inc(new int, source []byte) error
}
LookbackLimit provides an interface for a specific query limit.
type LookbackLimitOptions ¶
type LookbackLimitOptions struct {
// Limit past which errors will be returned.
Limit int64
// Lookback is the period over which the limit is enforced.
Lookback time.Duration
}
LookbackLimitOptions holds options for a lookback limit to be enforced.
func DefaultLookbackLimitOptions ¶
func DefaultLookbackLimitOptions() LookbackLimitOptions
DefaultLookbackLimitOptions returns a new query limits manager.
type Options ¶ added in v1.0.1
type Options interface {
// Validate validates the options.
Validate() error
// SetInstrumentOptions sets the instrument options.
SetInstrumentOptions(value instrument.Options) Options
// InstrumentOptions returns the instrument options.
InstrumentOptions() instrument.Options
// SetDocsLimitOpts sets the doc limit options.
SetDocsLimitOpts(value LookbackLimitOptions) Options
// DocsLimitOpts returns the doc limit options.
DocsLimitOpts() LookbackLimitOptions
// SetBytesReadLimitOpts sets the byte read limit options.
SetBytesReadLimitOpts(value LookbackLimitOptions) Options
// BytesReadLimitOpts returns the byte read limit options.
BytesReadLimitOpts() LookbackLimitOptions
// SetSourceLoggerBuilder sets the source logger.
SetSourceLoggerBuilder(value SourceLoggerBuilder) Options
// SourceLogger sets the source logger.
SourceLoggerBuilder() SourceLoggerBuilder
}
Options is a set of limit options.
func NewOptions ¶ added in v1.0.1
func NewOptions() Options
NewOptions creates limit options with default values.
type QueryLimits ¶
type QueryLimits interface {
// DocsLimit limits queries by a global concurrent count of index docs matched.
DocsLimit() LookbackLimit
// BytesReadLimit limits queries by a global concurrent count of bytes read from disk.
BytesReadLimit() LookbackLimit
// AnyExceeded returns an error if any of the query limits are exceeded.
AnyExceeded() error
// Start begins background resetting of the query limits.
Start()
// Stop end background resetting of the query limits.
Stop()
}
QueryLimits provides an interface for managing query limits.
func NewQueryLimits ¶
func NewQueryLimits( options Options, ) (QueryLimits, error)
NewQueryLimits returns a new query limits manager.
func NoOpQueryLimits ¶
func NoOpQueryLimits() QueryLimits
NoOpQueryLimits returns inactive query limits.
type SourceLogger ¶ added in v1.0.1
type SourceLogger interface {
// LogSourceValue attributes values that exceed a given size to the source.
LogSourceValue(val int64, source []byte)
}
SourceLogger attributes limit values to a source.
type SourceLoggerBuilder ¶ added in v1.0.1
type SourceLoggerBuilder interface {
// NewSourceLogger builds a source logger.
NewSourceLogger(name string, opts instrument.Options) SourceLogger
}
SourceLoggerBuilder builds a SourceLogger given instrument options.