handleroptions

package
v0.15.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2020 License: Apache-2.0 Imports: 15 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 (
	// WarningsHeader is the M3 warnings header when to display a warning to a user.
	WarningsHeader = "M3-Warnings"

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

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

	// DeprecatedHeader is the M3 deprecated header.
	DeprecatedHeader = "M3-Deprecated"

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

	// 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 = "M3-Storage-Policy"

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

	// LimitMaxSeriesHeader is the M3 limit timeseries header that limits
	// the number of time series returned by each storage node.
	LimitMaxSeriesHeader = "M3-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 = "M3-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 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 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"`
}

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"`
	Targets        []PromWriteHandlerForwardTargetOptions `yaml:"targets"`
}

PromWriteHandlerForwardingOptions is the forwarding options for prometheus write handler.

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.

Jump to

Keyboard shortcuts

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