handleroptions

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StepParam is the step parameter.
	StepParam = "step"
	// LookbackParam is the lookback parameter.
	LookbackParam = "lookback"
)
View Source
const (
	// M3HeaderPrefix is the prefix all M3-specific headers that affect query or
	// write behavior (not necessarily m3admin headers) are guaranteed to have.
	M3HeaderPrefix = "M3-"

	// WarningsHeader is the M3 warnings header when to display a warning to a user.
	WarningsHeader = M3HeaderPrefix + "Warnings"

	// RetryHeader is the M3 retry header to display when it is safe to retry.
	RetryHeader = M3HeaderPrefix + "Retry"

	// ServedByHeader is the M3 query storage execution breakdown.
	ServedByHeader = M3HeaderPrefix + "Storage-By"

	// DeprecatedHeader is the M3 deprecated header.
	DeprecatedHeader = M3HeaderPrefix + "Deprecated"

	// MetricsTypeHeader sets the write or read metrics type to restrict
	// metrics to.
	// Valid values are "unaggregated" or "aggregated".
	MetricsTypeHeader = M3HeaderPrefix + "Metrics-Type"

	// WriteTypeHeader is a header that controls if default
	// writes should be written to both unaggregated and aggregated
	// namespaces, or if unaggregated values are skipped and
	// only aggregated values are written.
	// Valid values are "default" or "aggregate".
	WriteTypeHeader = M3HeaderPrefix + "Write-Type"

	// DefaultWriteType is the default write type.
	DefaultWriteType = "default"

	// AggregateWriteType is the aggregate write type. This writes to
	// only aggregated namespaces
	AggregateWriteType = "aggregate"

	// MetricsStoragePolicyHeader specifies the resolution and retention of
	// metrics being written or read.
	// In the form of a storage policy string, e.g. "1m:14d".
	// Only required if the metrics type header does not specify unaggregated
	// metrics type.
	MetricsStoragePolicyHeader = M3HeaderPrefix + "Storage-Policy"

	// RestrictByTagsJSONHeader provides tag options to enforces on queries,
	// in JSON format. See `handler.stringTagOptions` for definitions.`
	RestrictByTagsJSONHeader = M3HeaderPrefix + "Restrict-By-Tags-JSON"

	// MapTagsByJSONHeader provides the ability to mutate tags of timeseries in
	// incoming write requests. See `MapTagsOptions` for structure.
	MapTagsByJSONHeader = M3HeaderPrefix + "Map-Tags-JSON"

	// LimitMaxSeriesHeader is the M3 limit timeseries header that limits
	// the number of time series returned by each storage node.
	LimitMaxSeriesHeader = M3HeaderPrefix + "Limit-Max-Series"

	// UnaggregatedStoragePolicy specifies the unaggregated storage policy.
	UnaggregatedStoragePolicy = "unaggregated"

	// DefaultServiceEnvironment is the default service ID environment.
	DefaultServiceEnvironment = "default_env"
	// DefaultServiceZone is the default service ID zone.
	DefaultServiceZone = "embedded"

	// HeaderClusterEnvironmentName is the header used to specify the environment
	// name.
	HeaderClusterEnvironmentName = "Cluster-Environment-Name"
	// HeaderClusterZoneName is the header used to specify the zone name.
	HeaderClusterZoneName = "Cluster-Zone-Name"
	// HeaderDryRun is the header used to specify whether this should be a dry
	// run.
	HeaderDryRun = "Dry-Run"
	// HeaderForce is the header used to specify whether this should be a forced operation.
	HeaderForce = "Force"

	// LimitHeader is the header added when returned series are limited.
	LimitHeader = M3HeaderPrefix + "Results-Limited"

	// LimitHeaderSeriesLimitApplied is the header applied when fetch results are
	// maxed.
	LimitHeaderSeriesLimitApplied = "max_fetch_series_limit_applied"
)
View Source
const (
	// M3DBServiceName is the service name for M3DB.
	M3DBServiceName = "m3db"
	// M3AggregatorServiceName is the service name for M3Aggregator.
	M3AggregatorServiceName = "m3aggregator"
	// M3CoordinatorServiceName is the service name for M3Coordinator.
	M3CoordinatorServiceName = "m3coordinator"
)

Variables

This section is empty.

Functions

func AddWarningHeaders

func AddWarningHeaders(w http.ResponseWriter, meta block.ResultMetadata)

AddWarningHeaders adds any warning headers present in the result's metadata. No-op if no warnings encountered.

func AllowedServices

func AllowedServices() []string

AllowedServices returns the list of valid M3 services.

func IsAllowedService

func IsAllowedService(svc string) bool

IsAllowedService returns whether a service name is a valid M3 service.

func ParseDuration

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

ParseDuration parses a duration HTTP parameter. nolint: unparam

func ParseLimit

func ParseLimit(req *http.Request, defaultLimit int) (int, error)

ParseLimit parses request limit 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 ParseStep

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

ParseStep parses the step duration for an HTTP request.

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(req *http.Request) (*storage.FetchOptions, *xhttp.ParseError)
}

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

func NewFetchOptionsBuilder

func NewFetchOptionsBuilder(
	opts FetchOptionsBuilderOptions,
) FetchOptionsBuilder

NewFetchOptionsBuilder returns a new fetch options builder.

type FetchOptionsBuilderOptions

type FetchOptionsBuilderOptions struct {
	Limit int
}

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

type M3AggServiceOptions

type M3AggServiceOptions struct {
	MaxAggregationWindowSize time.Duration
	WarmupDuration           time.Duration
}

M3AggServiceOptions contains the service options that are specific to the M3Agg service.

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 ServiceNameAndDefaults

type ServiceNameAndDefaults struct {
	ServiceName string
	Defaults    []ServiceOptionsDefault
}

ServiceNameAndDefaults is the params used when identifying a service and it's service option defaults.

type ServiceOptions

type ServiceOptions struct {
	ServiceName        string
	ServiceEnvironment string
	ServiceZone        string

	M3Agg *M3AggServiceOptions

	DryRun bool
	Force  bool
}

ServiceOptions are the options for Service.

func NewServiceOptions

func NewServiceOptions(
	service ServiceNameAndDefaults,
	headers http.Header,
	m3AggOpts *M3AggServiceOptions,
) ServiceOptions

NewServiceOptions returns a ServiceOptions based on the provided values.

func (*ServiceOptions) ServiceID

func (opts *ServiceOptions) ServiceID() services.ServiceID

ServiceID constructs a cluster services ID from the options.

func (*ServiceOptions) Validate

func (opts *ServiceOptions) Validate() error

Validate ensures the service options are valid.

type ServiceOptionsDefault

type ServiceOptionsDefault func(o ServiceOptions) ServiceOptions

ServiceOptionsDefault is a default to apply to service options.

func WithDefaultServiceEnvironment

func WithDefaultServiceEnvironment(env string) ServiceOptionsDefault

WithDefaultServiceEnvironment returns the default service environment.

func WithDefaultServiceZone

func WithDefaultServiceZone(zone string) ServiceOptionsDefault

WithDefaultServiceZone returns the default service zone.

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.

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