config

package
v16.1.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackgroundVerification

type BackgroundVerification struct {
	// VerificationInterval determines the duration after a replica due for reverification.
	// The feature is disabled if verification interval is 0 or below.
	VerificationInterval duration.Duration `toml:"verification_interval,omitempty"`
	// DeleteInvalidRecords controls whether the background verifier will actually delete the metadata
	// records that point to non-existent replicas.
	DeleteInvalidRecords bool `toml:"delete_invalid_records"`
}

BackgroundVerification contains configuration options for the repository background verification.

func DefaultBackgroundVerificationConfig

func DefaultBackgroundVerificationConfig() BackgroundVerification

DefaultBackgroundVerificationConfig returns the default background verification configuration.

func (BackgroundVerification) Validate

func (bv BackgroundVerification) Validate() error

Validate runs validation on all fields and compose all found errors.

type Config

type Config struct {
	AllowLegacyElectors    bool                   `toml:"i_understand_my_election_strategy_is_unsupported_and_will_be_removed_without_warning,omitempty"`
	BackgroundVerification BackgroundVerification `toml:"background_verification,omitempty"`
	Reconciliation         Reconciliation         `toml:"reconciliation,omitempty"`
	Replication            Replication            `toml:"replication,omitempty"`
	ListenAddr             string                 `toml:"listen_addr,omitempty"`
	TLSListenAddr          string                 `toml:"tls_listen_addr,omitempty"`
	SocketPath             string                 `toml:"socket_path,omitempty"`
	VirtualStorages        []*VirtualStorage      `toml:"virtual_storage,omitempty"`
	Logging                log.Config             `toml:"logging,omitempty"`
	Sentry                 sentry.Config          `toml:"sentry,omitempty"`
	PrometheusListenAddr   string                 `toml:"prometheus_listen_addr,omitempty"`
	Prometheus             prometheus.Config      `toml:"prometheus,omitempty"`
	Auth                   auth.Config            `toml:"auth,omitempty"`
	TLS                    config.TLS             `toml:"tls,omitempty"`
	DB                     `toml:"database,omitempty"`
	Failover               Failover            `toml:"failover,omitempty"`
	MemoryQueueEnabled     bool                `toml:"memory_queue_enabled,omitempty"`
	GracefulStopTimeout    duration.Duration   `toml:"graceful_stop_timeout,omitempty"`
	RepositoriesCleanup    RepositoriesCleanup `toml:"repositories_cleanup,omitempty"`
	Yamux                  Yamux               `toml:"yamux,omitempty"`
}

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 FromReader

func FromReader(reader io.Reader) (Config, error)

FromReader loads the config for the passed data stream.

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) ValidateV2

func (c *Config) ValidateV2() error

ValidateV2 is a new validation method that is a replacement for the existing Validate. It exists as a demonstration of the new validation implementation based on the usage of the cfgerror package.

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,omitempty"`
	Port        int    `toml:"port,omitempty"`
	User        string `toml:"user,omitempty"`
	Password    string `toml:"password,omitempty"`
	DBName      string `toml:"dbname,omitempty"`
	SSLMode     string `toml:"sslmode,omitempty"`
	SSLCert     string `toml:"sslcert,omitempty"`
	SSLKey      string `toml:"sslkey,omitempty"`
	SSLRootCert string `toml:"sslrootcert,omitempty"`

	SessionPooled DBConnection `toml:"session_pooled,omitempty"`

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

DB holds database configuration data.

type DBConnection

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

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 is a trigger used to check if failover is enabled or not.
	Enabled bool `toml:"enabled,omitempty"`
	// ElectionStrategy is the strategy to use for electing primaries nodes.
	ElectionStrategy         ElectionStrategy  `toml:"election_strategy,omitempty"`
	ErrorThresholdWindow     duration.Duration `toml:"error_threshold_window,omitempty"`
	WriteErrorThresholdCount uint32            `toml:"write_error_threshold_count,omitempty"`
	ReadErrorThresholdCount  uint32            `toml:"read_error_threshold_count,omitempty"`
	// BootstrapInterval allows set a time duration that would be used on startup to make initial health check.
	// The default value is 1s.
	BootstrapInterval duration.Duration `toml:"bootstrap_interval,omitempty"`
	// MonitorInterval allows set a time duration that would be used after bootstrap is completed to execute health checks.
	// The default value is 3s.
	MonitorInterval duration.Duration `toml:"monitor_interval,omitempty"`
}

Failover contains configuration for the mechanism that tracks healthiness of the cluster nodes.

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.

func (Failover) Validate

func (f Failover) Validate() error

Validate returns a list of failed checks.

type Node

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

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

func (Node) Validate

func (n Node) Validate() error

Validate runs validation on all fields and compose all found errors.

type Reconciliation

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

Reconciliation contains reconciliation specific configuration options.

func DefaultReconciliationConfig

func DefaultReconciliationConfig() Reconciliation

DefaultReconciliationConfig returns the default values for reconciliation configuration.

func (Reconciliation) Validate

func (r Reconciliation) Validate() error

Validate runs validation on all fields and compose all found errors.

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,omitempty"`
	// ParallelStorageProcessingWorkers is a number of workers used to process replication
	// events per virtual storage (how many storages would be processed in parallel).
	ParallelStorageProcessingWorkers uint `toml:"parallel_storage_processing_workers,omitempty"`
}

Replication contains replication specific configuration options.

func DefaultReplicationConfig

func DefaultReplicationConfig() Replication

DefaultReplicationConfig returns the default values for replication configuration.

func (Replication) Validate

func (r Replication) Validate() error

Validate runs validation on all fields and compose all found errors.

type RepositoriesCleanup

type RepositoriesCleanup struct {
	// CheckInterval is a time period used to check if operation should be executed.
	// It is recommended to keep it less than run_interval configuration as some
	// nodes may be out of service, so they can be stale for too long.
	CheckInterval duration.Duration `toml:"check_interval,omitempty"`
	// RunInterval: the check runs if the previous operation was done at least RunInterval before.
	RunInterval duration.Duration `toml:"run_interval,omitempty"`
	// RepositoriesInBatch is the number of repositories to pass as a batch for processing.
	RepositoriesInBatch uint `toml:"repositories_in_batch,omitempty"`
}

RepositoriesCleanup configures repository synchronisation.

func DefaultRepositoriesCleanup

func DefaultRepositoriesCleanup() RepositoriesCleanup

DefaultRepositoriesCleanup contains default configuration values for the RepositoriesCleanup.

func (RepositoriesCleanup) Validate

func (rc RepositoriesCleanup) Validate() error

Validate runs validation on all fields and compose all found errors.

type VirtualStorage

type VirtualStorage struct {
	Name  string  `toml:"name,omitempty"`
	Nodes []*Node `toml:"node,omitempty"`
	// 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,omitempty"`
}

VirtualStorage represents a set of nodes for a storage

func (VirtualStorage) Validate

func (vs VirtualStorage) Validate() error

Validate runs validation on all fields and compose all found errors.

type Yamux

type Yamux struct {
	// MaximumStreamWindowSizeBytes sets the maximum window size in bytes used for yamux streams.
	// Higher value can increase throughput at the cost of more memory usage.
	MaximumStreamWindowSizeBytes uint32 `toml:"maximum_stream_window_size_bytes,omitempty"`
	// AcceptBacklog sets the maximum number of stream openings in-flight before further openings
	// block.
	AcceptBacklog uint `toml:"accept_backlog,omitempty"`
}

Yamux contains Yamux related configuration values.

func DefaultYamuxConfig

func DefaultYamuxConfig() Yamux

DefaultYamuxConfig returns the default Yamux configuration values.

func (Yamux) Validate

func (cfg Yamux) Validate() error

Validate runs validation on all fields and compose all found errors.

Jump to

Keyboard shortcuts

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