options

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserRouterRequired     = errors.New("'user_router' block is required")
	ErrInvalidOutputFormat    = errors.New("value for 'output_format' is invalid")
	ErrOutputFormatOnlyForTSM = errors.New("'output_format' option is only valid for provider 'alb' and mechanism 'tsmerge'")
)

Functions

func NewErrInvalidALBOptions

func NewErrInvalidALBOptions(backendName string) error

NewErrInvalidALBOptions returns an invalid ALB Options error

func ValidateNoCycles added in v2.0.2

func ValidateNoCycles(albs map[string]*Options) error

ValidateNoCycles walks the ALB reference graph and returns an error if any ALB transitively references itself. The input maps ALB-backend name to its Options; non-ALB targets are leaves and ignored. A back edge to a node currently on the DFS stack is reported as a cycle.

Edges considered: (a) every entry of o.Pool, and (b) for ALBs configured with the user_router mechanism, o.UserRouter.DefaultBackend plus every o.UserRouter.Users[*].ToBackend. Without the user_router edges, a config like alb1.mechanism=user_router with user_router.default_backend=alb1 passes validation and exhausts the goroutine stack on the first request.

Types

type ConcurrencyOptions added in v2.0.1

type ConcurrencyOptions struct {
	// QueryConcurrencyLimit defines the concurrency limit while querying backends for the given mechanism.
	// If set to 0, no limit is applied, if set to a positive integer, that number of queries can be performed concurrently.
	// If the value is not set, it defaults to the number of logical CPUs available to the process (GOMAXPROCS).
	// Default value is GOMAXPROCS.
	QueryConcurrencyLimit *int `yaml:"query_concurrency_limit,omitempty"`

	// QueryConcurrencyMultiplier is a multiplier that can be applied to the default concurrency limit.
	// This multiplier is applied to the query_concurrency_limit value to result in the overall concurrency limit for the given mechanism.
	// Default and minimum value is 1.
	QueryConcurrencyMultiplier *int `yaml:"query_concurrency_multiplier,omitempty"`
}

Common concurrency options to apply to ALB mechanisms

func (*ConcurrencyOptions) GetQueryConcurrencyLimit added in v2.0.1

func (o *ConcurrencyOptions) GetQueryConcurrencyLimit() int

type FirstGoodResponseOptions added in v2.0.1

type FirstGoodResponseOptions struct {
	// StatusCodes provides an explicit list of status codes considered "good" when using
	// the First Good Response (fgr) methodology. By default, any code < 400 is good.
	StatusCodes        []int              `yaml:"status_codes,omitempty"`
	ConcurrencyOptions ConcurrencyOptions `yaml:",inline"`
}

type InvalidALBOptionsError

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

InvalidALBOptionsError is an error type for invalid ALB Options

type NewestLastModifiedOptions added in v2.0.1

type NewestLastModifiedOptions struct {
	ConcurrencyOptions ConcurrencyOptions `yaml:",inline"`
}

type Options

type Options struct {
	// MechanismName indicates the name of the load balancing mechanism
	MechanismName string `yaml:"mechanism,omitempty"`
	// Pool provides the list of backend names to be used by the load balancer
	Pool []string `yaml:"pool,omitempty"`
	// HealthyFloor is the minimum health check status value admitted to the pool.
	// Values below 0 admit members the probe has confirmed Failing; only set
	// this below 0 if you intend to route to known-broken upstreams.
	// -1 : all pool members admitted, including Failing
	//  0 (default) : Unknown (0) and Healthy (1) admitted, Failing rejected
	//  1 : only Healthy (1) admitted
	// Unknown means the first health check hasn't returned yet, or the target
	// backend has no health check interval configured.
	HealthyFloor int `yaml:"healthy_floor,omitempty"`
	// MaxCaptureBytes overrides the backend-level max_capture_bytes for this
	// ALB's fanout members. Set this when the ALB's expected response shape
	// differs from the backend default (e.g. a TSM fan-out of 50 small-payload
	// shards may safely use a lower cap than the global default to surface
	// runaway upstreams faster). When 0, falls back to the parent Backend's
	// max_capture_bytes, then to the package-level default (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.
	// When 0, falls back to the parent Backend's max_fanout_capture_bytes,
	// which itself defaults to 0 (no aggregate cap).
	MaxFanoutCaptureBytes int `yaml:"max_fanout_capture_bytes,omitempty"`
	// OutputFormat accompanies the tsmerge Mechanism to indicate the provider output format
	// options include any valid time seres backend like prometheus, influxdb or clickhouse
	OutputFormat string `yaml:"output_format,omitempty"`
	// Deprecated: use fgr.status_codes instead of this top-level option
	// FGRStatusCodes provides an explicit list of status codes considered "good" when using
	// the First Good Response (fgr) methodology. By default, any code < 400 is good.
	FGRStatusCodes []int `yaml:"fgr_status_codes,omitempty"`
	// UserRouter provides options for the User Router mechanism
	UserRouter *ur.Options `yaml:"user_router,omitempty"`
	//
	// synthetic values
	FgrCodesLookup sets.Set[int] `yaml:"-"`

	// mechanism-specific options
	TSMOptions TimeSeriesMergeOptions    `yaml:"tsm,omitempty"`
	NLMOptions NewestLastModifiedOptions `yaml:"nlm,omitempty"`
	FGROptions FirstGoodResponseOptions  `yaml:"fgr,omitempty"`
}

Options defines options for ALBs

func New

func New() *Options

New returns a New Options object with the default values

func (*Options) Clone

func (o *Options) Clone() *Options

Clone returns a perfect copy of the Options

func (*Options) Initialize

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

func (*Options) UnmarshalYAML

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

func (*Options) Validate

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

func (*Options) ValidatePool

func (o *Options) ValidatePool(backendName string, allBackends sets.Set[string]) error

type TimeSeriesMergeOptions added in v2.0.1

type TimeSeriesMergeOptions struct {
	ConcurrencyOptions ConcurrencyOptions `yaml:",inline"`
	// DedupToleranceMs is an opt-in tolerance window (milliseconds) for
	// clustering near-duplicate samples produced by independent fan-out
	// shards. When two shards sample the same metric at timestamps that
	// differ by <= this many milliseconds, the cluster collapses to a single
	// survivor (first-seen-after-sort wins). Nil or 0 preserves the legacy
	// exact-epoch dedup behavior.
	DedupToleranceMs *int `yaml:"dedup_tolerance_ms,omitempty"`
}

Jump to

Keyboard shortcuts

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