options

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 31 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// DefaultTimeseriesTTL is the default Cache TTL for Time Series Objects
	DefaultTimeseriesTTL = 6 * time.Hour
	// DefaultFastForwardTTL is the default Cache TTL for Time Series Fast Forward Objects
	DefaultFastForwardTTL = 15 * time.Second
	// DefaultMaxTTL is the default Maximum TTL of any cache object
	DefaultMaxTTL = 25 * time.Hour
	// DefaultRevalidationFactor is the default Cache Object Freshness Lifetime to TTL multiplier
	DefaultRevalidationFactor = 2
	// DefaultMaxObjectSizeBytes is the default Max Size of any Cache Object
	DefaultMaxObjectSizeBytes = 524288
	// DefaultMaxCaptureBytes is the default per-response capture-buffer cap,
	// applied to Trickster's internal response captures (ALB fanout, Prometheus
	// label/transform handlers, etc.). Set to 256 MiB to protect against a
	// single misbehaving upstream OOM'ing the proxy; an N-way ALB fanout would
	// otherwise allocate O(N*M) on the heap if each member returned an
	// M-byte body.
	DefaultMaxCaptureBytes = 256 * 1024 * 1024
	// DefaultMaxFanoutCaptureBytes is the default aggregate cap (sum of all
	// in-flight per-slot capture reservations within a single ALB fanout
	// call). 0 disables the aggregate cap and preserves the existing
	// behavior where every slot reserves up to MaxCaptureBytes
	// independently. Operators who want to bound the worst-case
	// N*MaxCaptureBytes heap pressure of a wide fanout should set this
	// explicitly.
	DefaultMaxFanoutCaptureBytes = 0
	// DefaultBackendTRF is the default Timeseries Retention Factor for Time Series-based Backends
	DefaultBackendTRF = 1024
	// DefaultBackendTEM is the default Timeseries Eviction Method for Time Series-based Backends
	DefaultBackendTEM = evictionmethods.EvictionMethodOldest
	// DefaultBackendTEMName is the default Timeseries Eviction Method name for Time Series-based Backends
	DefaultBackendTEMName = "oldest"
	// DefaultBackendTimeout is the default Upstream Request Timeout for Backends
	DefaultBackendTimeout = 1 * time.Minute
	// DefaultBackendCacheName is the default Cache Name for Backends
	DefaultBackendCacheName = "default"
	// DefaultBackendNegativeCacheName is the default Negative Cache Name for Backends
	DefaultBackendNegativeCacheName = "default"
	// DefaultTracingConfigName is the default Tracing Config Name for Backends
	DefaultTracingConfigName = "default"
	// DefaultBackfillTolerance is the default Backfill Tolerance setting for Backends
	DefaultBackfillTolerance = 0 * time.Millisecond
	// DefaultBackfillTolerancePoints is the default Backfill Tolerance setting for Backends
	DefaultBackfillTolerancePoints = 0
	// DefaultKeepAliveTimeout is the default Keep Alive Timeout for Backends' upstream client pools
	DefaultKeepAliveTimeout = 2 * time.Minute
	// DefaultMaxIdleConns is the default number of Idle Connections in Backends' upstream client pools
	DefaultMaxIdleConns = 20
	// DefaultMaxConcurrentConns is the default max number of concurrent connections to the origin the Backend can use
	DefaultMaxConcurrentConns = 20
	// DefaultForwardedHeaders defines which class of 'Forwarded' headers are attached to upstream requests
	DefaultForwardedHeaders = "standard"
	// DefaultALBMechanismName defines the default ALB Mechanism Name
	DefaultALBMechanismName = names.MechanismRR // round robin
	// DefaultTimeseriesShardSize defines the default shard size of 0 (no sharding)
	DefaultTimeseriesShardSize = 0
	// DefaultTimeseriesShardStep defines the default shard step of 0 (no sharding)
	DefaultTimeseriesShardStep = 0
	// DefaultChunkReadConcurrencyLimit defines the default chunk read concurrency limit
	DefaultChunkReadConcurrencyLimit = 16
	// DefaultChunkReadConcurrencyLimit defines the default chunk write concurrency limit
	DefaultChunkWriteConcurrencyLimit = 16
	// DefaultFetchConcurrencyLimit defines the default max concurrent upstream fetch requests
	// when retrieving missing time-series extents
	DefaultFetchConcurrencyLimit = 16
)

Variables

View Source
var ErrInvalidMaxShardSize = errors.New(
	"'shard_max_size_time' and 'shard_max_size_points' cannot both be non-zero")

ErrInvalidMaxShardSize is an error for when both 'shard_max_size_time' and 'shard_max_size_points' are used on the same backend

View Source
var ErrInvalidMaxShardSizeTime = errors.New(
	"'shard_max_size_time' must be a multiple of 'shard_step' when both are non-zero")

ErrInvalidMaxShardSizeTime is an error for when 'shard_max_size_time' is not a multiple 'shard_step'

View Source
var ErrInvalidMetadata = errors.New("invalid options metadata")

ErrInvalidMetadata is an error for invalid metadata

Functions

func DefaultCompressibleTypes

func DefaultCompressibleTypes() []string

DefaultCompressibleTypes returns a list of types that Trickster should compress before caching

func NewErrInvalidAuthenticatorName

func NewErrInvalidAuthenticatorName(authenticatorName, backendName string) error

NewErrInvalidAuthenticatorName returns a new invalid authenticator name error

func NewErrInvalidBackendName

func NewErrInvalidBackendName(backendName string) error

NewErrInvalidBackendName returns a new invalid backend name error

func NewErrInvalidCacheName

func NewErrInvalidCacheName(cacheName, backendName string) error

NewErrInvalidCacheName returns a new invalid cache name error

func NewErrInvalidNegativeCacheName

func NewErrInvalidNegativeCacheName(cacheName string) error

NewErrInvalidNegativeCacheName returns a new invalid negative cache name error

func NewErrInvalidRewriterName

func NewErrInvalidRewriterName(rewriterName, backendName string) error

NewErrInvalidRewriterName returns a new missing invalid rewriter name error

func NewErrInvalidRuleName

func NewErrInvalidRuleName(ruleName, backendName string) error

NewErrInvalidRuleName returns a new invalid rule name error

func NewErrInvalidTracingName

func NewErrInvalidTracingName(tracingName, backendName string) error

NewErrInvalidTracingName returns a new invalid tracing name error

func NewErrMissingOriginURL

func NewErrMissingOriginURL(backendName string) error

NewErrMissingOriginURL returns a new missing origin URL error

func NewErrMissingProvider

func NewErrMissingProvider(backendName string) error

NewErrMissingProvider returns a new missing provider error

func ValidateBackendName

func ValidateBackendName(name string) error

ValidateBackendName ensures the backend name is permitted against the dictionary of restricted words

Types

type ErrInvalidAuthenticatorName

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

ErrInvalidAuthenticatorName is an error type for invalid cache name

type ErrInvalidBackendName

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

ErrInvalidBackendName is an error type for invalid backend name

type ErrInvalidCacheName

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

ErrInvalidCacheName is an error type for invalid cache name

type ErrInvalidNegativeCacheName

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

ErrInvalidNegativeCacheName is an error type for invalid negative cache name

type ErrInvalidRewriterName

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

ErrInvalidRewriterName is an error type for invalid rewriter name

type ErrInvalidRuleName

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

ErrInvalidRuleName is an error type for invalid rule name

type ErrInvalidTracingName

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

ErrInvalidTracingName is an error type for invalid tracing name

type ErrMissingOriginURL

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

ErrMissingOriginURL is an error type for missing origin URL

type ErrMissingProvider

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

ErrMissingProvider is an error type for missing provider

type Lookup

type Lookup map[string]*Options

Lookup is a map of Options

func (Lookup) Initialize

func (l Lookup) Initialize() error

func (Lookup) Keys

func (l Lookup) Keys() sets.Set[string]

func (Lookup) Validate

func (l Lookup) Validate() error

Validate validates the Lookup collection of Backend Options

func (Lookup) ValidateConfigMappings

func (l Lookup) ValidateConfigMappings(c co.Lookup, ncl negative.Lookups,
	rul ro.Lookup, rwl rwopts.Lookup, a autho.Lookup, tr tro.Lookup,
) error

ValidateConfigMappings ensures that named config mappings from within origin configs (e.g., backends.cache_name) are valid

func (Lookup) ValidateTLSConfigs

func (l Lookup) ValidateTLSConfigs() (bool, error)

ValidateTLSConfigs iterates the map and validates any Options that use TLS

type Options

type Options struct {
	// HTTP and Proxy Configurations
	//
	// Hosts identifies the frontend hostnames this backend should handle (virtual hosting)
	Hosts []string `yaml:"hosts,omitempty"`
	// Provider describes the type of backend (e.g., 'prometheus')
	Provider string `yaml:"provider,omitempty"`
	// OriginURL provides the base upstream URL for all proxied requests to this Backend.
	// it can be as simple as http://example.com or as complex as https://example.com:8443/path/prefix
	OriginURL string `yaml:"origin_url,omitempty"`
	// Timeout defines how long the HTTP request will wait for a response before timing out
	Timeout time.Duration `yaml:"timeout,omitempty"`
	// KeepAliveTimeout defines how long an open keep-alive HTTP connection remains idle before closing
	KeepAliveTimeout time.Duration `yaml:"keep_alive_timeout,omitempty"`
	// MaxConcurrentConns defines maximum number of open concurrent connections to maintain to the backend
	MaxConcurrentConns int `yaml:"max_concurrent_conns,omitempty"`
	// MaxIdleConns defines maximum number of open keep-alive connections to maintain
	MaxIdleConns int `yaml:"max_idle_conns,omitempty"`
	// CacheName provides the name of the configured cache where the backend client will store it's cache data
	CacheName string `yaml:"cache_name,omitempty"`
	// CacheKeyPrefix defines the cache key prefix the backend will use when writing objects to the cache
	CacheKeyPrefix string `yaml:"cache_key_prefix,omitempty"`
	// ChunkReadConcurrencyLimit defines the concurrency limit while reading a chunked object
	ChunkReadConcurrencyLimit int `yaml:"chunk_read_concurrency_limit,omitempty"`
	// FetchConcurrencyLimit defines the max concurrent upstream requests when fetching
	// missing time-series extents in the Delta Proxy Cache
	FetchConcurrencyLimit int `yaml:"fetch_concurrency_limit,omitempty"`
	// ChunkWriteConcurrencyLimit defines the concurrency limit while writing a chunked object
	ChunkWriteConcurrencyLimit int `yaml:"chunk_write_concurrency_limit,omitempty"`
	// HealthCheck is the health check options reference for this backend
	HealthCheck *ho.Options `yaml:"healthcheck,omitempty"`
	// Object Proxy Cache and Delta Proxy Cache Configurations
	// TimeseriesRetentionFactor limits the maximum the number of chronological
	// timestamps worth of data to store in cache for each query
	TimeseriesRetentionFactor int `yaml:"timeseries_retention_factor,omitempty"`
	// TimeseriesEvictionMethodName specifies which methodology ("oldest", "lru") is used to identify
	// timeseries to evict from a full cache object
	TimeseriesEvictionMethodName string `yaml:"timeseries_eviction_method,omitempty"`
	// BackfillTolerance prevents values with timestamps newer than the provided number of
	// milliseconds from being cached. this allows propagation of upstream backfill operations
	// that modify recently-cached data
	BackfillTolerance time.Duration `yaml:"backfill_tolerance,omitempty"`
	// BackfillTolerancePoints is similar to the MS version, except that it's final value is dependent
	// on the query step value to determine the relative duration of backfill tolerance per-query
	// When both are set, the higher of the two values is used
	BackfillTolerancePoints int `yaml:"backfill_tolerance_points,omitempty"`
	// Paths is a list of Path Options that control the behavior of the given paths when requested
	Paths po.List `yaml:"paths,omitempty"`
	// NegativeCacheName provides the name of the Negative Cache Config to be used by this Backend
	NegativeCacheName string `yaml:"negative_cache_name,omitempty"`
	// TimeseriesTTL specifies the cache TTL of timeseries objects
	TimeseriesTTL time.Duration `yaml:"timeseries_ttl,omitempty"`
	// TimeseriesTTLMS specifies the cache TTL of fast forward data
	FastForwardTTL time.Duration `yaml:"fastforward_ttl,omitempty"`
	// MaxTTL specifies the maximum allowed TTL for any cache object
	MaxTTL time.Duration `yaml:"max_ttl,omitempty"`
	// RevalidationFactor specifies how many times to multiply the object freshness lifetime
	// by to calculate an absolute cache TTL
	RevalidationFactor float64 `yaml:"revalidation_factor,omitempty"`
	// MaxObjectSizeBytes specifies the max objectsize to be accepted for any given cache object
	MaxObjectSizeBytes int `yaml:"max_object_size_bytes,omitempty"`
	// MaxCaptureBytes caps the per-response in-memory capture buffer that
	// Trickster's internal capture writer allocates when an ALB mechanism
	// fans out to pool members or a backend handler transforms an upstream
	// response. A member whose body exceeds the cap is treated as a
	// partial-failure (the merge surfaces an X-Trickster-Result phit marker)
	// rather than truncating the response silently. Defaults to 256 MiB.
	MaxCaptureBytes int `yaml:"max_capture_bytes,omitempty"`
	// MaxFanoutCaptureBytes, if > 0, caps the aggregate in-flight
	// capture-buffer reservations across all slots in one ALB fanout call.
	// Each slot reserves the per-slot MaxCaptureBytes worst case; slots
	// dispatched after the budget is exhausted are fail-fasted so the
	// merge sees them as failures and existing partial-merge / 502
	// fallback paths handle them. Defaults to 0 (no aggregate cap).
	MaxFanoutCaptureBytes int `yaml:"max_fanout_capture_bytes,omitempty"`
	// CompressibleTypeList specifies the HTTP Object Content Types that will be compressed internally
	// when stored in the Trickster cache or served to clients with a compatible 'Accept-Encoding' header
	CompressibleTypeList []string `yaml:"compressible_types,omitempty"`
	// TracingConfigName provides the name of the Tracing Config to be used by this Backend
	TracingConfigName string `yaml:"tracing_name,omitempty"`
	// RuleName provides the name of the rule config to be used by this backend.
	// This is only effective if the Backend provider is 'rule'
	RuleName string `yaml:"rule_name,omitempty"`
	// ReqRewriterName is the name of a configured Rewriter that will modify the request prior to
	// processing by the backend client
	ReqRewriterName string `yaml:"req_rewriter_name,omitempty"`
	// MaxShardSizePoints defines the maximum size of a timeseries request in unique timestamps,
	// before sharding into multiple requests of this denomination and reconsitituting the results.
	// If MaxShardSizePoints and MaxShardSizeMS are both > 0, the configuration is invalid
	MaxShardSizePoints int `yaml:"shard_max_size_points,omitempty"`
	// MaxShardSizeTime defines the max size of a timeseries request,
	// before sharding into multiple requests of this denomination and reconsitituting the results.
	// If MaxShardSizePoints and MaxShardSizeTime are both > 0, the configuration is invalid
	MaxShardSizeTime time.Duration `yaml:"shard_max_size_time,omitempty"`
	// ShardStep defines the epoch-aligned cadence to use when creating shards. When set to 0,
	// shards are not aligned to the epoch at a specific step. MaxShardSizeMS must be perfectly
	// divisible by ShardStep when both are > 0, or the configuration is invalid
	ShardStep time.Duration `yaml:"shard_step,omitempty"`
	// ProxyOnly, when true, will cause this backend to bypass caching while handling the request
	ProxyOnly bool `yaml:"proxy_only,omitempty"`

	// ALBOptions holds the options for ALBs
	ALBOptions *ao.Options `yaml:"alb,omitempty"`
	// Prometheus holds options specific to prometheus backends
	Prometheus *prop.Options `yaml:"prometheus,omitempty"`

	// TLS is the TLS Configuration for the Frontend and Backend
	TLS *to.Options `yaml:"tls,omitempty"`

	// ForwardedHeaders indicates the class of 'Forwarded' header to attach to upstream requests
	ForwardedHeaders string `yaml:"forwarded_headers,omitempty"`

	// IsDefault indicates if this is the d.Default backend for any request not matching a configured route
	IsDefault bool `yaml:"is_default,omitempty"`
	// FastForwardDisable indicates whether the FastForward feature should be disabled for this backend
	FastForwardDisable bool `yaml:"fast_forward_disable,omitempty"`
	// PathRoutingDisabled, when true, will bypass /backendName/path route registrations
	PathRoutingDisabled bool `yaml:"path_routing_disabled,omitempty"`
	// RequireTLS, when true, indicates this Backend Config's paths must only be registered with the TLS Router
	RequireTLS bool `yaml:"require_tls,omitempty"`
	// MultipartRangesDisabled, when true, indicates that if a downstream client requests multiple ranges
	// in a single request, Trickster will instead request and return a 200 OK with the full object body
	MultipartRangesDisabled bool `yaml:"multipart_ranges_disabled,omitempty"`
	// DearticulateUpstreamRanges, when true, indicates that when Trickster requests multiple ranges from
	// the backend, that they be requested as individual upstream requests instead of a single request that
	// expects a multipart response	// this optimizes Trickster to request as few bytes as possible when
	// fronting backends that only support single range requests
	DearticulateUpstreamRanges bool `yaml:"dearticulate_upstream_ranges,omitempty"`
	// Authentication
	// AuthenticatorName specifies the name of the optional Authenticator to attach to this Backend, and
	// can be overridden at the Path level.
	AuthenticatorName string `yaml:"authenticator_name,omitempty"`
	// AWS SigV4
	SigV4 *sigv4.SigV4Config `yaml:"sigv4,omitempty"`

	// Simulated Latency
	// When LatencyMin > 0 and LatencyMaxMS < LatencyMin (e.g., 0), then LatencyMin of latency
	// are applied to the request. When LatencyMaxMS > LatencyMin, then a random amount of
	// latency between the two values will be applied to the request
	//
	// LatencyMin is the minimum amount of simulated latency to apply to each incoming request
	LatencyMin time.Duration `yaml:"latency_min"`
	// LatencyMax is the maximum amount of simulated latency to apply to each incoming request
	LatencyMax time.Duration `yaml:"latency_max"`

	// Synthesized Configurations
	// These configurations are parsed versions of those defined above, and are what Trickster uses internally
	//
	// Name is the Name of the backend, taken from the Key in the Backends Lookup Map
	Name string `yaml:"-"`
	// Router is a router.Router containing this backend's Path Routes; it is set during route registration
	Router router.Router `yaml:"-"`
	// Scheme is the layer 7 protocol indicator (e.g. 'http'), derived from OriginURL
	Scheme string `yaml:"-"`
	// Host is the upstream hostname/IP[:port] the backend client will connect to when fetching uncached data,
	// derived from OriginURL
	Host string `yaml:"-"`
	// PathPrefix provides any prefix added to the front of the requested path when constructing the upstream
	// request url, derived from OriginURL
	PathPrefix string `yaml:"-"`
	// NegativeCache provides a map for the negative cache, with TTLs converted to time.Durations
	NegativeCache negative.Lookup `yaml:"-"`
	// TimeseriesRetention when subtracted from time.Now() represents the oldest allowable timestamp in a
	// timeseries when EvictionMethod is 'oldest'
	TimeseriesRetention time.Duration `yaml:"-"`
	// TimeseriesEvictionMethod is the parsed value of TimeseriesEvictionMethodName
	TimeseriesEvictionMethod evictionmethods.TimeseriesEvictionMethod `yaml:"-"`
	// FastForwardPath is the paths.Options to use for upstream Fast Forward Requests
	FastForwardPath *po.Options `yaml:"-"`
	// HTTPClient is the Client used by Trickster to communicate with the origin
	HTTPClient *http.Client `yaml:"-"`
	// CompressibleTypes is the map version of CompressibleTypeList for fast lookup
	CompressibleTypes sets.Set[string] `yaml:"-"`
	// RuleOptions is the reference to the Rule Options as indicated by RuleName
	RuleOptions *ro.Options `yaml:"-"`
	// ReqRewriter is the rewriter handler as indicated by RuleName
	ReqRewriter rewriter.RewriteInstructions `yaml:"-"`
	// AuthOptions is the authenticator as indicated by AuthenticatorName
	AuthOptions *autho.Options `yaml:"-"`
	// DoesShard is true when sharding will be used with this origin, based on how the
	// sharding options have been configured
	DoesShard bool `yaml:"-"`
}

Options is a collection of configurations for Trickster backends

func New

func New() *Options

New will return a pointer to a Backend Options with the default configuration settings

func (*Options) Clone

func (o *Options) Clone() *Options

Clone returns an exact copy of an *backends.Options

func (*Options) CloneYAMLSafe

func (o *Options) CloneYAMLSafe() *Options

CloneYAMLSafe returns a copy of the Options that is safe to export to YAML without exposing credentials (by masking known credential fields with "*****")

func (*Options) Initialize

func (o *Options) Initialize(name string) error

Initialize sets up the backend Options with default values and overlays any values that were set during YAML unmarshaling

func (*Options) ToYAML

func (o *Options) ToYAML() string

ToYAML prints the Options as a YAML representation

func (*Options) UnmarshalYAML

func (o *Options) UnmarshalYAML(unmarshal func(any) error) error

func (*Options) Validate

func (o *Options) Validate() (bool, error)

Validate validates the Backend Options

Jump to

Keyboard shortcuts

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