limits

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package limits is a generated GoMock package.

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

func IsQueryLimitExceededError(err error) bool

IsQueryLimitExceededError returns true if the error is a query limits exceeded error.

func NewQueryLimitExceededError added in v1.0.1

func NewQueryLimitExceededError(msg string) error

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 {
	// Options returns the current limit options.
	Options() LookbackLimitOptions
	// Inc increments the recent value for the limit.
	Inc(val int, source []byte) error
	// Update changes the lookback limit settings.
	Update(opts LookbackLimitOptions) error

	// Start begins background resetting of the lookback limit.
	Start()
	// Stop end background resetting of the lookback limit.
	Stop()
}

LookbackLimit provides an interface for a specific query limit.

func NewLookbackLimit added in v1.2.0

func NewLookbackLimit(
	name string,
	opts LookbackLimitOptions,
	instrumentOpts instrument.Options,
	sourceLoggerBuilder SourceLoggerBuilder,
) LookbackLimit

NewLookbackLimit returns a new lookback limit.

type LookbackLimitOptions

type LookbackLimitOptions struct {
	// Limit past which errors will be returned.
	// Zero disables the limit.
	Limit int64
	// Lookback is the period over which the limit is enforced.
	Lookback time.Duration
	// ForceExceeded, if true, makes all calls to the limit behave as though the limit is exceeded.
	ForceExceeded bool
	// ForceWaited, if true, makes all calls to the limit behave as though the caller waited for permits.
	ForceWaited bool
}

LookbackLimitOptions holds options for a lookback limit to be enforced.

func DefaultLookbackLimitOptions

func DefaultLookbackLimitOptions() LookbackLimitOptions

DefaultLookbackLimitOptions returns a new query limits manager.

func (LookbackLimitOptions) Equals added in v1.0.1

func (opts LookbackLimitOptions) Equals(other LookbackLimitOptions) bool

Equals returns true if the other options match the current.

type MockLookbackLimit added in v1.6.0

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

MockLookbackLimit is a mock of LookbackLimit interface.

func NewMockLookbackLimit added in v1.6.0

func NewMockLookbackLimit(ctrl *gomock.Controller) *MockLookbackLimit

NewMockLookbackLimit creates a new mock instance.

func (*MockLookbackLimit) EXPECT added in v1.6.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockLookbackLimit) Inc added in v1.6.0

func (m *MockLookbackLimit) Inc(new int, source []byte) error

Inc mocks base method.

func (*MockLookbackLimit) Options added in v1.6.0

Options mocks base method.

func (*MockLookbackLimit) Start added in v1.6.0

func (m *MockLookbackLimit) Start()

Start mocks base method.

func (*MockLookbackLimit) Stop added in v1.6.0

func (m *MockLookbackLimit) Stop()

Stop mocks base method.

func (*MockLookbackLimit) Update added in v1.6.0

Update mocks base method.

type MockLookbackLimitMockRecorder added in v1.6.0

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

MockLookbackLimitMockRecorder is the mock recorder for MockLookbackLimit.

func (*MockLookbackLimitMockRecorder) Inc added in v1.6.0

func (mr *MockLookbackLimitMockRecorder) Inc(new, source interface{}) *gomock.Call

Inc indicates an expected call of Inc.

func (*MockLookbackLimitMockRecorder) Options added in v1.6.0

func (mr *MockLookbackLimitMockRecorder) Options() *gomock.Call

Options indicates an expected call of Options.

func (*MockLookbackLimitMockRecorder) Start added in v1.6.0

Start indicates an expected call of Start.

func (*MockLookbackLimitMockRecorder) Stop added in v1.6.0

Stop indicates an expected call of Stop.

func (*MockLookbackLimitMockRecorder) Update added in v1.6.0

func (mr *MockLookbackLimitMockRecorder) Update(opts interface{}) *gomock.Call

Update indicates an expected call of Update.

type MockOptions added in v1.6.0

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

MockOptions is a mock of Options interface.

func NewMockOptions added in v1.6.0

func NewMockOptions(ctrl *gomock.Controller) *MockOptions

NewMockOptions creates a new mock instance.

func (*MockOptions) AggregateDocsLimitOpts added in v1.6.0

func (m *MockOptions) AggregateDocsLimitOpts() LookbackLimitOptions

AggregateDocsLimitOpts mocks base method.

func (*MockOptions) BytesReadLimitOpts added in v1.6.0

func (m *MockOptions) BytesReadLimitOpts() LookbackLimitOptions

BytesReadLimitOpts mocks base method.

func (*MockOptions) DiskSeriesReadLimitOpts added in v1.6.0

func (m *MockOptions) DiskSeriesReadLimitOpts() LookbackLimitOptions

DiskSeriesReadLimitOpts mocks base method.

func (*MockOptions) DocsLimitOpts added in v1.6.0

func (m *MockOptions) DocsLimitOpts() LookbackLimitOptions

DocsLimitOpts mocks base method.

func (*MockOptions) EXPECT added in v1.6.0

func (m *MockOptions) EXPECT() *MockOptionsMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockOptions) InstrumentOptions added in v1.6.0

func (m *MockOptions) InstrumentOptions() instrument.Options

InstrumentOptions mocks base method.

func (*MockOptions) SetAggregateDocsLimitOpts added in v1.6.0

func (m *MockOptions) SetAggregateDocsLimitOpts(arg0 LookbackLimitOptions) Options

SetAggregateDocsLimitOpts mocks base method.

func (*MockOptions) SetBytesReadLimitOpts added in v1.6.0

func (m *MockOptions) SetBytesReadLimitOpts(value LookbackLimitOptions) Options

SetBytesReadLimitOpts mocks base method.

func (*MockOptions) SetDiskSeriesReadLimitOpts added in v1.6.0

func (m *MockOptions) SetDiskSeriesReadLimitOpts(value LookbackLimitOptions) Options

SetDiskSeriesReadLimitOpts mocks base method.

func (*MockOptions) SetDocsLimitOpts added in v1.6.0

func (m *MockOptions) SetDocsLimitOpts(value LookbackLimitOptions) Options

SetDocsLimitOpts mocks base method.

func (*MockOptions) SetInstrumentOptions added in v1.6.0

func (m *MockOptions) SetInstrumentOptions(value instrument.Options) Options

SetInstrumentOptions mocks base method.

func (*MockOptions) SetSourceLoggerBuilder added in v1.6.0

func (m *MockOptions) SetSourceLoggerBuilder(value SourceLoggerBuilder) Options

SetSourceLoggerBuilder mocks base method.

func (*MockOptions) SourceLoggerBuilder added in v1.6.0

func (m *MockOptions) SourceLoggerBuilder() SourceLoggerBuilder

SourceLoggerBuilder mocks base method.

func (*MockOptions) Validate added in v1.6.0

func (m *MockOptions) Validate() error

Validate mocks base method.

type MockOptionsMockRecorder added in v1.6.0

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

MockOptionsMockRecorder is the mock recorder for MockOptions.

func (*MockOptionsMockRecorder) AggregateDocsLimitOpts added in v1.6.0

func (mr *MockOptionsMockRecorder) AggregateDocsLimitOpts() *gomock.Call

AggregateDocsLimitOpts indicates an expected call of AggregateDocsLimitOpts.

func (*MockOptionsMockRecorder) BytesReadLimitOpts added in v1.6.0

func (mr *MockOptionsMockRecorder) BytesReadLimitOpts() *gomock.Call

BytesReadLimitOpts indicates an expected call of BytesReadLimitOpts.

func (*MockOptionsMockRecorder) DiskSeriesReadLimitOpts added in v1.6.0

func (mr *MockOptionsMockRecorder) DiskSeriesReadLimitOpts() *gomock.Call

DiskSeriesReadLimitOpts indicates an expected call of DiskSeriesReadLimitOpts.

func (*MockOptionsMockRecorder) DocsLimitOpts added in v1.6.0

func (mr *MockOptionsMockRecorder) DocsLimitOpts() *gomock.Call

DocsLimitOpts indicates an expected call of DocsLimitOpts.

func (*MockOptionsMockRecorder) InstrumentOptions added in v1.6.0

func (mr *MockOptionsMockRecorder) InstrumentOptions() *gomock.Call

InstrumentOptions indicates an expected call of InstrumentOptions.

func (*MockOptionsMockRecorder) SetAggregateDocsLimitOpts added in v1.6.0

func (mr *MockOptionsMockRecorder) SetAggregateDocsLimitOpts(arg0 interface{}) *gomock.Call

SetAggregateDocsLimitOpts indicates an expected call of SetAggregateDocsLimitOpts.

func (*MockOptionsMockRecorder) SetBytesReadLimitOpts added in v1.6.0

func (mr *MockOptionsMockRecorder) SetBytesReadLimitOpts(value interface{}) *gomock.Call

SetBytesReadLimitOpts indicates an expected call of SetBytesReadLimitOpts.

func (*MockOptionsMockRecorder) SetDiskSeriesReadLimitOpts added in v1.6.0

func (mr *MockOptionsMockRecorder) SetDiskSeriesReadLimitOpts(value interface{}) *gomock.Call

SetDiskSeriesReadLimitOpts indicates an expected call of SetDiskSeriesReadLimitOpts.

func (*MockOptionsMockRecorder) SetDocsLimitOpts added in v1.6.0

func (mr *MockOptionsMockRecorder) SetDocsLimitOpts(value interface{}) *gomock.Call

SetDocsLimitOpts indicates an expected call of SetDocsLimitOpts.

func (*MockOptionsMockRecorder) SetInstrumentOptions added in v1.6.0

func (mr *MockOptionsMockRecorder) SetInstrumentOptions(value interface{}) *gomock.Call

SetInstrumentOptions indicates an expected call of SetInstrumentOptions.

func (*MockOptionsMockRecorder) SetSourceLoggerBuilder added in v1.6.0

func (mr *MockOptionsMockRecorder) SetSourceLoggerBuilder(value interface{}) *gomock.Call

SetSourceLoggerBuilder indicates an expected call of SetSourceLoggerBuilder.

func (*MockOptionsMockRecorder) SourceLoggerBuilder added in v1.6.0

func (mr *MockOptionsMockRecorder) SourceLoggerBuilder() *gomock.Call

SourceLoggerBuilder indicates an expected call of SourceLoggerBuilder.

func (*MockOptionsMockRecorder) Validate added in v1.6.0

func (mr *MockOptionsMockRecorder) Validate() *gomock.Call

Validate indicates an expected call of Validate.

type MockQueryLimits added in v1.6.0

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

MockQueryLimits is a mock of QueryLimits interface.

func NewMockQueryLimits added in v1.6.0

func NewMockQueryLimits(ctrl *gomock.Controller) *MockQueryLimits

NewMockQueryLimits creates a new mock instance.

func (*MockQueryLimits) AggregateDocsLimit added in v1.6.0

func (m *MockQueryLimits) AggregateDocsLimit() LookbackLimit

AggregateDocsLimit mocks base method.

func (*MockQueryLimits) AnyFetchExceeded added in v1.6.0

func (m *MockQueryLimits) AnyFetchExceeded() error

AnyFetchExceeded mocks base method.

func (*MockQueryLimits) BytesReadLimit added in v1.6.0

func (m *MockQueryLimits) BytesReadLimit() LookbackLimit

BytesReadLimit mocks base method.

func (*MockQueryLimits) EXPECT added in v1.6.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockQueryLimits) FetchDocsLimit added in v1.6.0

func (m *MockQueryLimits) FetchDocsLimit() LookbackLimit

FetchDocsLimit mocks base method.

func (*MockQueryLimits) Start added in v1.6.0

func (m *MockQueryLimits) Start()

Start mocks base method.

func (*MockQueryLimits) Stop added in v1.6.0

func (m *MockQueryLimits) Stop()

Stop mocks base method.

type MockQueryLimitsMockRecorder added in v1.6.0

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

MockQueryLimitsMockRecorder is the mock recorder for MockQueryLimits.

func (*MockQueryLimitsMockRecorder) AggregateDocsLimit added in v1.6.0

func (mr *MockQueryLimitsMockRecorder) AggregateDocsLimit() *gomock.Call

AggregateDocsLimit indicates an expected call of AggregateDocsLimit.

func (*MockQueryLimitsMockRecorder) AnyFetchExceeded added in v1.6.0

func (mr *MockQueryLimitsMockRecorder) AnyFetchExceeded() *gomock.Call

AnyFetchExceeded indicates an expected call of AnyFetchExceeded.

func (*MockQueryLimitsMockRecorder) BytesReadLimit added in v1.6.0

func (mr *MockQueryLimitsMockRecorder) BytesReadLimit() *gomock.Call

BytesReadLimit indicates an expected call of BytesReadLimit.

func (*MockQueryLimitsMockRecorder) FetchDocsLimit added in v1.6.0

func (mr *MockQueryLimitsMockRecorder) FetchDocsLimit() *gomock.Call

FetchDocsLimit indicates an expected call of FetchDocsLimit.

func (*MockQueryLimitsMockRecorder) Start added in v1.6.0

Start indicates an expected call of Start.

func (*MockQueryLimitsMockRecorder) Stop added in v1.6.0

Stop indicates an expected call of Stop.

type MockSourceLogger added in v1.6.0

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

MockSourceLogger is a mock of SourceLogger interface.

func NewMockSourceLogger added in v1.6.0

func NewMockSourceLogger(ctrl *gomock.Controller) *MockSourceLogger

NewMockSourceLogger creates a new mock instance.

func (*MockSourceLogger) EXPECT added in v1.6.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockSourceLogger) LogSourceValue added in v1.6.0

func (m *MockSourceLogger) LogSourceValue(val int64, source []byte)

LogSourceValue mocks base method.

type MockSourceLoggerBuilder added in v1.6.0

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

MockSourceLoggerBuilder is a mock of SourceLoggerBuilder interface.

func NewMockSourceLoggerBuilder added in v1.6.0

func NewMockSourceLoggerBuilder(ctrl *gomock.Controller) *MockSourceLoggerBuilder

NewMockSourceLoggerBuilder creates a new mock instance.

func (*MockSourceLoggerBuilder) EXPECT added in v1.6.0

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockSourceLoggerBuilder) NewSourceLogger added in v1.6.0

func (m *MockSourceLoggerBuilder) NewSourceLogger(name string, opts instrument.Options) SourceLogger

NewSourceLogger mocks base method.

type MockSourceLoggerBuilderMockRecorder added in v1.6.0

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

MockSourceLoggerBuilderMockRecorder is the mock recorder for MockSourceLoggerBuilder.

func (*MockSourceLoggerBuilderMockRecorder) NewSourceLogger added in v1.6.0

func (mr *MockSourceLoggerBuilderMockRecorder) NewSourceLogger(name, opts interface{}) *gomock.Call

NewSourceLogger indicates an expected call of NewSourceLogger.

type MockSourceLoggerMockRecorder added in v1.6.0

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

MockSourceLoggerMockRecorder is the mock recorder for MockSourceLogger.

func (*MockSourceLoggerMockRecorder) LogSourceValue added in v1.6.0

func (mr *MockSourceLoggerMockRecorder) LogSourceValue(val, source interface{}) *gomock.Call

LogSourceValue indicates an expected call of LogSourceValue.

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

	// SetAggregateDocsLimitOpts sets the aggregate doc limit options.
	SetAggregateDocsLimitOpts(LookbackLimitOptions) Options

	// AggregateDocsLimitOpts returns the aggregate doc limit options.
	AggregateDocsLimitOpts() LookbackLimitOptions

	// SetDiskSeriesReadLimitOpts sets the disk series read limit options.
	SetDiskSeriesReadLimitOpts(value LookbackLimitOptions) Options

	// DiskSeriesReadLimitOpts returns the disk series read limit options.
	DiskSeriesReadLimitOpts() 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 DefaultLimitsOptions added in v1.2.0

func DefaultLimitsOptions(iOpts instrument.Options) Options

DefaultLimitsOptions is the set of default limits options.

func NewOptions added in v1.0.1

func NewOptions() Options

NewOptions creates limit options with default values.

type QueryLimits

type QueryLimits interface {
	// FetchDocsLimit limits queries by a global concurrent count of index docs matched.
	FetchDocsLimit() LookbackLimit
	// BytesReadLimit limits queries by a global concurrent count of bytes read from disk.
	BytesReadLimit() LookbackLimit
	// AnyFetchExceeded returns an error if any of the query limits are exceeded on
	// a fetch query.
	AnyFetchExceeded() error

	// AggregateDocsLimit limits aggregate queries by a global
	// concurrent count of index docs matched.
	AggregateDocsLimit() LookbackLimit

	// 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.

Directories

Path Synopsis
Package permits is a generated GoMock package.
Package permits is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL