config

package
v14.0.12 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	AllowLegacyElectors  bool              `toml:"i_understand_my_election_strategy_is_unsupported_and_will_be_removed_without_warning"`
	Reconciliation       Reconciliation    `toml:"reconciliation"`
	Replication          Replication       `toml:"replication"`
	ListenAddr           string            `toml:"listen_addr"`
	TLSListenAddr        string            `toml:"tls_listen_addr"`
	SocketPath           string            `toml:"socket_path"`
	VirtualStorages      []*VirtualStorage `toml:"virtual_storage"`
	Logging              log.Config        `toml:"logging"`
	Sentry               sentry.Config     `toml:"sentry"`
	PrometheusListenAddr string            `toml:"prometheus_listen_addr"`
	Prometheus           prometheus.Config `toml:"prometheus"`
	Auth                 auth.Config       `toml:"auth"`
	TLS                  config.TLS        `toml:"tls"`
	DB                   `toml:"database"`
	Failover             Failover `toml:"failover"`
	// Keep for legacy reasons: remove after Omnibus has switched
	FailoverEnabled     bool            `toml:"failover_enabled"`
	MemoryQueueEnabled  bool            `toml:"memory_queue_enabled"`
	GracefulStopTimeout config.Duration `toml:"graceful_stop_timeout"`
}

Config is a container for everything found in the TOML config file

func FromFile

func FromFile(filePath string) (Config, error)

FromFile loads the config for the passed file path

func (Config) ConfigureLogger

func (c Config) ConfigureLogger() *logrus.Entry

ConfigureLogger applies the settings from the configuration file to the logger, setting the log level and format.

func (Config) DefaultReplicationFactors

func (c Config) DefaultReplicationFactors() map[string]int

DefaultReplicationFactors returns a map with the default replication factors of the virtual storages.

func (*Config) NeedsSQL

func (c *Config) NeedsSQL() bool

NeedsSQL returns true if the driver for SQL needs to be initialized

func (*Config) StorageNames

func (c *Config) StorageNames() map[string][]string

StorageNames returns storage names by virtual storage.

func (*Config) Validate

func (c *Config) Validate() error

Validate establishes if the config is valid

func (*Config) VirtualStorageNames

func (c *Config) VirtualStorageNames() []string

VirtualStorageNames returns names of all virtual storages configured.

type DB

type DB struct {
	Host        string `toml:"host"`
	Port        int    `toml:"port"`
	User        string `toml:"user"`
	Password    string `toml:"password"`
	DBName      string `toml:"dbname"`
	SSLMode     string `toml:"sslmode"`
	SSLCert     string `toml:"sslcert"`
	SSLKey      string `toml:"sslkey"`
	SSLRootCert string `toml:"sslrootcert"`

	SessionPooled DBConnection `toml:"session_pooled"`

	// The following configuration keys are deprecated and
	// will be removed. Use Host and Port attributes of
	// SessionPooled instead.
	HostNoProxy string `toml:"host_no_proxy"`
	PortNoProxy int    `toml:"port_no_proxy"`
}

DB holds database configuration data.

func (DB) ToPQString

func (db DB) ToPQString(direct bool) string

ToPQString returns a connection string that can be passed to github.com/lib/pq.

type DBConnection

type DBConnection struct {
	Host        string `toml:"host"`
	Port        int    `toml:"port"`
	User        string `toml:"user"`
	Password    string `toml:"password"`
	DBName      string `toml:"dbname"`
	SSLMode     string `toml:"sslmode"`
	SSLCert     string `toml:"sslcert"`
	SSLKey      string `toml:"sslkey"`
	SSLRootCert string `toml:"sslrootcert"`
}

DBConnection holds Postgres client configuration data.

type ElectionStrategy

type ElectionStrategy string

ElectionStrategy is a Praefect primary election strategy.

const (
	// ElectionStrategyLocal configures a single node, in-memory election strategy.
	ElectionStrategyLocal ElectionStrategy = "local"
	// ElectionStrategySQL configures an SQL based strategy that elects a primary for a virtual storage.
	ElectionStrategySQL ElectionStrategy = "sql"
	// ElectionStrategyPerRepository configures an SQL based strategy that elects different primaries per repository.
	ElectionStrategyPerRepository ElectionStrategy = "per_repository"
)

type Failover

type Failover struct {
	Enabled bool `toml:"enabled"`
	// ElectionStrategy is the strategy to use for electing primaries nodes.
	ElectionStrategy         ElectionStrategy `toml:"election_strategy"`
	ErrorThresholdWindow     config.Duration  `toml:"error_threshold_window"`
	WriteErrorThresholdCount uint32           `toml:"write_error_threshold_count"`
	ReadErrorThresholdCount  uint32           `toml:"read_error_threshold_count"`
	// BootstrapInterval allows set a time duration that would be used on startup to make initial health check.
	// The default value is 1s.
	BootstrapInterval config.Duration `toml:"bootstrap_interval"`
	// MonitorInterval allows set a time duration that would be used after bootstrap is completed to execute health checks.
	// The default value is 3s.
	MonitorInterval config.Duration `toml:"monitor_interval"`
}

func (Failover) ErrorThresholdsConfigured

func (f Failover) ErrorThresholdsConfigured() (bool, error)

ErrorThresholdsConfigured checks whether returns whether the errors thresholds are configured. If they are configured but in an invalid way, an error is returned.

type Node

type Node struct {
	Storage string `toml:"storage"`
	Address string `toml:"address"`
	Token   string `toml:"token"`
}

Node describes an address that serves a storage

func (Node) MarshalJSON

func (n Node) MarshalJSON() ([]byte, error)

func (Node) String

func (n Node) String() string

String prints out the node attributes but hiding the token

type Reconciliation

type Reconciliation struct {
	// SchedulingInterval the interval between each automatic reconciliation run. If set to 0,
	// automatic reconciliation is disabled.
	SchedulingInterval config.Duration `toml:"scheduling_interval"`
	// HistogramBuckets configures the reconciliation scheduling duration histogram's buckets.
	HistogramBuckets []float64 `toml:"histogram_buckets"`
}

Reconciliation contains reconciliation specific configuration options.

func DefaultReconciliationConfig

func DefaultReconciliationConfig() Reconciliation

DefaultReconciliationConfig returns the default values for reconciliation configuration.

type Replication

type Replication struct {
	// BatchSize controls how many replication jobs to dequeue and lock
	// in a single call to the database.
	BatchSize uint `toml:"batch_size"`
}

Replication contains replication specific configuration options.

func DefaultReplicationConfig

func DefaultReplicationConfig() Replication

DefaultReplicationConfig returns the default values for replication configuration.

type VirtualStorage

type VirtualStorage struct {
	Name  string  `toml:"name"`
	Nodes []*Node `toml:"node"`
	// DefaultReplicationFactor is the replication factor set for new repositories.
	// A valid value is inclusive between 1 and the number of configured storages in the
	// virtual storage. Setting the value to 0 or below causes Praefect to not store any
	// host assignments, falling back to the behavior of replicating to every configured
	// storage
	DefaultReplicationFactor int `toml:"default_replication_factor"`
}

VirtualStorage represents a set of nodes for a storage

Jump to

Keyboard shortcuts

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