config

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2026 License: BSD-2-Clause, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultGracefulShutdownTimeout = 10 * time.Second
	DefaultGracefulReloadTimeout   = 30 * time.Second
	DefaultDisconnectRateLimit     = 100 // connections per second
	DefaultDisconnectBurstSize     = 10
)

Default values for graceful shutdown

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	Nodes []string `yaml:"nodes" json:"nodes"`
}

type Config

type Config struct {
	Upstreams              []Upstream       `yaml:"upstreams" json:"upstreams"`
	HandshakeTimeout       Duration         `yaml:"handshake_timeout,omitempty" json:"handshake_timeout,omitempty"`
	ConnectionCloseTimeout Duration         `yaml:"connection_close_timeout,omitempty" json:"connection_close_timeout,omitempty"`
	GracefulShutdown       GracefulShutdown `yaml:"graceful_shutdown,omitempty" json:"graceful_shutdown"`
}

Config represents the configuration of the trabbits proxy.

func Load

func Load(ctx context.Context, f string) (*Config, error)

func (*Config) Hash

func (c *Config) Hash() string

Hash calculates SHA256 hash of the config using gob encoding

func (*Config) SetDefaults

func (c *Config) SetDefaults()

SetDefaults sets default values for config fields if not specified

func (*Config) String

func (c *Config) String() string

func (*Config) Validate

func (c *Config) Validate() error

type Duration

type Duration time.Duration

Duration is a custom type that can unmarshal duration strings from JSON

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (Duration) String

func (d Duration) String() string

String returns string representation

func (Duration) ToDuration

func (d Duration) ToDuration() time.Duration

ToDuration converts to time.Duration

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type GracefulShutdown

type GracefulShutdown struct {
	ShutdownTimeout Duration `yaml:"shutdown_timeout,omitempty" json:"shutdown_timeout,omitempty"` // Max time to wait for shutdown (SIGTERM)
	ReloadTimeout   Duration `yaml:"reload_timeout,omitempty" json:"reload_timeout,omitempty"`     // Max time to wait for config reload (SIGHUP)
	RateLimit       int      `yaml:"rate_limit,omitempty" json:"rate_limit,omitempty"`             // Disconnections per second
	BurstSize       int      `yaml:"burst_size,omitempty" json:"burst_size,omitempty"`             // Initial burst allowance
}

GracefulShutdown configures graceful shutdown behavior

type HealthCheck

type HealthCheck struct {
	Interval           Duration `yaml:"interval,omitempty" json:"interval,omitempty"`
	Timeout            Duration `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	UnhealthyThreshold int      `yaml:"unhealthy_threshold,omitempty" json:"unhealthy_threshold,omitempty"`
	RecoveryInterval   Duration `yaml:"recovery_interval,omitempty" json:"recovery_interval,omitempty"`
	Username           string   `yaml:"username,omitempty" json:"username,omitempty"`
	Password           Password `yaml:"password,omitempty" json:"password,omitempty"`
}

HealthCheck represents health check configuration for cluster upstreams

type Password

type Password string

Password is a custom type that masks the value during JSON marshaling

func (Password) MarshalJSON

func (p Password) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface to mask password

func (Password) String

func (p Password) String() string

String returns the actual password value (for internal use)

func (*Password) UnmarshalJSON

func (p *Password) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler interface

type QueueAttributes

type QueueAttributes struct {
	Durable    *bool         `yaml:"durable,omitempty" json:"durable,omitempty"`
	AutoDelete *bool         `yaml:"auto_delete,omitempty" json:"auto_delete,omitempty"`
	Exclusive  *bool         `yaml:"exclusive,omitempty" json:"exclusive,omitempty"`
	Arguments  amqp091.Table `yaml:"arguments,omitempty" json:"arguments,omitempty"`
}

type QueueOptions added in v0.0.14

type QueueOptions struct {
	TryPassive        bool `yaml:"try_passive,omitempty" json:"try_passive,omitempty"`
	EmulateAutoDelete bool `yaml:"emulate_auto_delete,omitempty" json:"emulate_auto_delete,omitempty"`
}

type Routing

type Routing struct {
	KeyPatterns []string `yaml:"key_patterns,omitempty" json:"key_patterns,omitempty"`
}

type Upstream

type Upstream struct {
	Name        string       `yaml:"name" json:"name"`
	Address     string       `yaml:"address,omitempty" json:"address,omitempty"`
	Cluster     *Cluster     `yaml:"cluster,omitempty" json:"cluster,omitempty"`
	Timeout     Duration     `yaml:"timeout,omitempty" json:"timeout,omitempty"`
	HealthCheck *HealthCheck `yaml:"health_check,omitempty" json:"health_check,omitempty"`

	Routing         Routing          `yaml:"routing,omitempty" json:"routing"`
	QueueAttributes *QueueAttributes `yaml:"queue_attributes,omitempty" json:"queue_attributes,omitempty"`
	QueueOptions    *QueueOptions    `yaml:"queue_options,omitempty" json:"queue_options,omitempty"`
}

Upstream represents the configuration of an upstream server.

func (*Upstream) Addresses

func (u *Upstream) Addresses() []string

func (*Upstream) Validate

func (u *Upstream) Validate() error

Jump to

Keyboard shortcuts

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