handler

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: Apache-2.0 Imports: 18 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"

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

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

	// 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"
)
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"
)
View Source
const (
	// SearchURL is the url to search for metric ids
	SearchURL = "/search"

	// SearchHTTPMethod is the HTTP method used with this resource.
	SearchHTTPMethod = http.MethodPost
)

Variables

This section is empty.

Functions

func AllowedServices added in v0.7.0

func AllowedServices() []string

AllowedServices returns the list of valid M3 services.

func CloseWatcher

func CloseWatcher(
	ctx context.Context,
	cancel context.CancelFunc,
	w http.ResponseWriter,
	instrumentOpts instrument.Options,
)

CloseWatcher watches for CloseNotify and context timeout. It is best effort and may sometimes not close the channel relying on gc

func IsAllowedService added in v0.7.0

func IsAllowedService(svc string) bool

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

func NewSearchHandler

func NewSearchHandler(
	storage storage.Storage,
	fetchOptionsBuilder FetchOptionsBuilder,
	instrumentOpts instrument.Options,
) http.Handler

NewSearchHandler returns a new instance of handler

func ParseDuration added in v0.11.0

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

ParseDuration parses a duration HTTP parameter. nolint: unparam

func ParseLookbackDuration added in v0.11.0

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

ParseLookbackDuration parses a lookback duration for an HTTP request.

func ParseStep added in v0.11.0

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

ParseStep parses the step duration for an HTTP request.

Types

type FetchOptionsBuilder added in v0.9.2

type FetchOptionsBuilder interface {
	NewFetchOptions(req *http.Request) (*storage.FetchOptions, *xhttp.ParseError)
}

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

func NewFetchOptionsBuilder added in v0.9.2

func NewFetchOptionsBuilder(
	opts FetchOptionsBuilderOptions,
) FetchOptionsBuilder

NewFetchOptionsBuilder returns a new fetch options builder.

type FetchOptionsBuilderOptions added in v0.9.2

type FetchOptionsBuilderOptions struct {
	Limit int
}

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

type HeaderKeyType added in v0.4.5

type HeaderKeyType int

HeaderKeyType is the type for the header key

const (
	// HeaderKey is the key which headers will be added to in the request context
	HeaderKey HeaderKeyType = iota

	// RoutePrefixV1 is the v1 prefix for all coordinator routes
	RoutePrefixV1 = "/api/v1"
)

type M3AggServiceOptions added in v0.7.0

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

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

type SearchHandler

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

SearchHandler represents a handler for the search endpoint

func (*SearchHandler) ServeHTTP

func (h *SearchHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ServiceOptions added in v0.7.0

type ServiceOptions struct {
	ServiceName        string
	ServiceEnvironment string
	ServiceZone        string

	M3Agg *M3AggServiceOptions

	DryRun bool
	Force  bool
}

ServiceOptions are the options for Service.

func NewServiceOptions added in v0.7.0

func NewServiceOptions(
	serviceName string, headers http.Header, m3AggOpts *M3AggServiceOptions) ServiceOptions

NewServiceOptions returns a ServiceOptions based on the provided values.

func (*ServiceOptions) ServiceID added in v0.7.0

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

ServiceID constructs a cluster services ID from the options.

func (*ServiceOptions) Validate added in v0.7.0

func (opts *ServiceOptions) Validate() error

Validate ensures the service options are valid.

Jump to

Keyboard shortcuts

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