handleroptions

package
Version: v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RequestHeaderKey is the key which headers will be added to in the
	// request context.
	RequestHeaderKey headerKey = "RequestHeaderKey"
	// StepParam is the step parameter.
	StepParam = "step"
	// LookbackParam is the lookback parameter.
	LookbackParam = "lookback"
	// TimeoutParam is the timeout parameter.
	TimeoutParam = "timeout"
)

Variables

This section is empty.

Functions

func AddDBResultResponseHeaders added in v1.2.0

func AddDBResultResponseHeaders(
	w http.ResponseWriter,
	meta block.ResultMetadata,
	fetchOpts *storage.FetchOptions,
) error

AddDBResultResponseHeaders adds response headers based on metadata and fetch options related to the database result.

func AddReturnedLimitResponseHeaders added in v1.2.0

func AddReturnedLimitResponseHeaders(
	w http.ResponseWriter,
	returnedDataLimited *ReturnedDataLimited,
	returnedMetadataLimited *ReturnedMetadataLimited,
) error

AddReturnedLimitResponseHeaders adds headers related to hitting limits on the allowed amount of data that can be returned to the client.

func ParseDuration

func ParseDuration(r *http.Request, key string) (time.Duration, error)

ParseDuration parses a duration HTTP parameter. nolint: unparam

func ParseDurationLimit added in v1.2.0

func ParseDurationLimit(
	req *http.Request,
	header,
	formValue string,
	defaultLimit time.Duration,
) (time.Duration, error)

ParseDurationLimit parses request limit from either header or query string.

func ParseInstanceMultiple added in v1.2.0

func ParseInstanceMultiple(req *http.Request, defaultValue float32) (float32, error)

ParseInstanceMultiple parses request instance multiple from header.

func ParseIterateEqualTimestampStrategy added in v1.4.2

func ParseIterateEqualTimestampStrategy(
	req *http.Request, header, formValue string,
) (*encoding.IterateEqualTimestampStrategy, error)

ParseIterateEqualTimestampStrategy parses the IterateEqualTimestampStrategy from either header or query string.

func ParseLookbackDuration

func ParseLookbackDuration(r *http.Request) (time.Duration, bool, error)

ParseLookbackDuration parses a lookback duration for an HTTP request.

func ParseReadConsistencyLevel added in v1.4.2

func ParseReadConsistencyLevel(
	req *http.Request, header, formValue string,
) (*topology.ReadConsistencyLevel, error)

ParseReadConsistencyLevel parses the ReadConsistencyLevel from either header or query string.

func ParseRelatedQueryOptions added in v1.4.0

func ParseRelatedQueryOptions(r *http.Request) (*storage.RelatedQueryOptions, bool, error)

ParseRelatedQueryOptions parses the RelatedQueryOptions struct out of the request it returns ok==false if no such options exist

func ParseRequestTimeout added in v1.0.1

func ParseRequestTimeout(
	r *http.Request,
	configFetchTimeout time.Duration,
) (time.Duration, error)

ParseRequestTimeout parses the input request timeout with a default.

func ParseRequireExhaustive added in v0.15.2

func ParseRequireExhaustive(req *http.Request, defaultValue bool) (bool, error)

ParseRequireExhaustive parses request limit require exhaustive from header or query string.

func ParseRequireNoWait added in v1.2.0

func ParseRequireNoWait(req *http.Request) (bool, error)

ParseRequireNoWait parses the no-wait behavior from header or query string.

func ParseStep

func ParseStep(r *http.Request) (time.Duration, bool, error)

ParseStep parses the step duration for an HTTP request.

func ParseValue added in v1.4.2

func ParseValue(req *http.Request, header, formValue string, defaultValue int) (int, error)

ParseLimit parses request limit from either header or query string.

Types

type DropOp

type DropOp struct {
	Tag string `json:"tag"`
}

DropOp with tag="foo" and an empty value will remove all tag-value pairs in all timeseries in the write request where the tag was "foo".

func (DropOp) IsEmpty

func (op DropOp) IsEmpty() bool

IsEmpty returns true if the operation is empty.

type DropWithValueOp

type DropWithValueOp struct {
	Tag   string `json:"tag"`
	Value string `json:"value"`
}

DropWithValueOp will remove all tag-value pairs in all timeseries in the writer equest if and only if the tag AND value in the timeseries is equal to those on the operation.

func (DropWithValueOp) IsEmpty

func (op DropWithValueOp) IsEmpty() bool

IsEmpty returns true if the operation is empty.

type FetchOptionsBuilder

type FetchOptionsBuilder interface {
	// NewFetchOptions parses an http request into fetch options.
	NewFetchOptions(
		ctx context.Context,
		req *http.Request,
	) (context.Context, *storage.FetchOptions, error)
}

FetchOptionsBuilder builds fetch options based on a request and default config.

func NewFetchOptionsBuilder

func NewFetchOptionsBuilder(
	opts FetchOptionsBuilderOptions,
) (FetchOptionsBuilder, error)

NewFetchOptionsBuilder returns a new fetch options builder.

type FetchOptionsBuilderLimitsOptions added in v0.15.4

type FetchOptionsBuilderLimitsOptions struct {
	SeriesLimit                 int
	InstanceMultiple            float32
	DocsLimit                   int
	RangeLimit                  time.Duration
	ReturnedSeriesLimit         int
	ReturnedDatapointsLimit     int
	ReturnedSeriesMetadataLimit int
	RequireExhaustive           bool
	MaxMetricMetadataStats      int
}

FetchOptionsBuilderLimitsOptions provides limits options to use when creating a fetch options builder.

type FetchOptionsBuilderOptions

type FetchOptionsBuilderOptions struct {
	Limits        FetchOptionsBuilderLimitsOptions
	RestrictByTag *storage.RestrictByTag
	Timeout       time.Duration
}

FetchOptionsBuilderOptions provides options to use when creating a fetch options builder.

func (FetchOptionsBuilderOptions) Validate added in v1.0.1

func (o FetchOptionsBuilderOptions) Validate() error

Validate validates the fetch options builder options.

type MapTagsOptions

type MapTagsOptions struct {
	TagMappers []TagMapper `json:"tagMappers"`
}

MapTagsOptions representations mutations to be applied to all timeseries in a write request.

type PromWriteHandlerForwardTargetOptions

type PromWriteHandlerForwardTargetOptions struct {
	// URL of the target to send to.
	URL string `yaml:"url"`
	// Method defaults to POST if not set.
	Method string `yaml:"method"`
	// Headers to send along with requests to the target.
	Headers map[string]string `yaml:"headers"`
}

PromWriteHandlerForwardTargetOptions is a prometheus write handler forwarder target.

type PromWriteHandlerForwardingOptions

type PromWriteHandlerForwardingOptions struct {
	// MaxConcurrency is the max parallel forwarding and if zero will be unlimited.
	MaxConcurrency int                                    `yaml:"maxConcurrency"`
	Timeout        time.Duration                          `yaml:"timeout"`
	Retry          *retry.Configuration                   `yaml:"retry"`
	Targets        []PromWriteHandlerForwardTargetOptions `yaml:"targets"`
}

PromWriteHandlerForwardingOptions is the forwarding options for prometheus write handler.

type ReplaceOp

type ReplaceOp struct {
	Tag      string `json:"tag"`
	OldValue string `json:"old"`
	NewValue string `json:"new"`
}

ReplaceOp with tag="foo", an empty old field, and a non-empty new field will unconditionally replace the value of any tag-value pair of any timeseries in the write request where the tag is "foo" with the value of new. If old is non-empty, a value will only be replaced if the value was equal to old.

func (ReplaceOp) IsEmpty

func (op ReplaceOp) IsEmpty() bool

IsEmpty returns true if the operation is empty.

type ReturnedDataLimited added in v1.2.0

type ReturnedDataLimited struct {
	Series     int
	Datapoints int

	// Total series is the total number of series which maybe be >= Series.
	// Truncation happens at the series-level to avoid presenting partial series
	// and so this value is useful for indicating how many series would have
	// been rendered without limiting either series or datapoints.
	TotalSeries int

	// Limited signals that the results returned were
	// limited by either series or datapoint limits.
	Limited bool
}

ReturnedDataLimited is info about whether data was limited by a query.

type ReturnedMetadataLimited added in v1.2.0

type ReturnedMetadataLimited struct {
	// Results is the total amount of rendered results.
	Results int
	// TotalResults is the total amount of metadata results.
	TotalResults int
	// Limited signals that the results returned were limited by a limit.
	Limited bool
}

ReturnedMetadataLimited is info about whether data was limited by a query.

type StringMatch

type StringMatch struct {
	Name  string `json:"name"`
	Type  string `json:"type"`
	Value string `json:"value"`
}

StringMatch is an easy to use JSON representation of models.Matcher that allows plaintext fields rather than forcing base64 encoded values.

type StringTagOptions

type StringTagOptions struct {
	Restrict []StringMatch `json:"match"`
	Strip    []string      `json:"strip"`
}

StringTagOptions is an easy to use JSON representation of storage.RestrictByTag that allows plaintext string fields rather than forcing base64 encoded values.

func (*StringTagOptions) StorageOptions added in v0.15.4

func (o *StringTagOptions) StorageOptions() (*storage.RestrictByTag, error)

StorageOptions returns the corresponding storage.RestrictByTag options.

func (*StringTagOptions) Validate added in v0.15.4

func (o *StringTagOptions) Validate() error

Validate validates the string tag options.

type TagMapper

type TagMapper struct {
	Write         WriteOp         `json:"write,omitEmpty"`
	Drop          DropOp          `json:"drop,omitEmpty"`
	DropWithValue DropWithValueOp `json:"dropWithValue,omitEmpty"`
	Replace       ReplaceOp       `json:"replace,omitEmpty"`
}

TagMapper represents one of a variety of tag mapping operations.

func (TagMapper) Validate

func (t TagMapper) Validate() error

Validate ensures the mapper is valid.

type Waiting added in v1.2.0

type Waiting struct {
	// WaitedIndex counts how many times index querying had to wait for permits.
	WaitedIndex int `json:"waitedIndex"`
	// WaitedSeriesRead counts how many times series being read had to wait for permits.
	WaitedSeriesRead int `json:"waitedSeriesRead"`
}

Waiting is info about an operation waiting for permits.

func (Waiting) WaitedAny added in v1.2.0

func (w Waiting) WaitedAny() bool

WaitedAny returns whether any waiting occurred.

type WriteOp

type WriteOp struct {
	Tag   string `json:"tag"`
	Value string `json:"value"`
}

WriteOp with value tag="foo" and value="bar" will unconditionally add tag-value pair "foo":"bar" to all timeseries included in the write request. Any timeseries with a non-empty "foo" tag will have its value for that tag replaced.

func (WriteOp) IsEmpty

func (op WriteOp) IsEmpty() bool

IsEmpty returns true if the operation is empty.

Jump to

Keyboard shortcuts

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