config

package
v16.11.2 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 19 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" json:"verification_interval"`
	// DeleteInvalidRecords controls whether the background verifier will actually delete the metadata
	// records that point to non-existent replicas.
	DeleteInvalidRecords bool `toml:"delete_invalid_records" json:"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 {
	// ConfigCommand specifies the path to an executable that Praefect will run after loading the initial
	// configuration. The executable is expected to write JSON-formatted configuration to its standard
	// output that we will then deserialize and merge back into the initially-loaded configuration again.
	// This is an easy mechanism to generate parts of the configuration at runtime, like for example secrets.
	ConfigCommand          string                 `toml:"config_command,omitempty" json:"config_command"`
	AllowLegacyElectors    bool                   `` /* 193-byte string literal not displayed */
	BackgroundVerification BackgroundVerification `toml:"background_verification,omitempty" json:"background_verification"`
	Reconciliation         Reconciliation         `toml:"reconciliation,omitempty" json:"reconciliation"`
	Replication            Replication            `toml:"replication,omitempty" json:"replication"`
	ListenAddr             string                 `toml:"listen_addr,omitempty" json:"listen_addr"`
	TLSListenAddr          string                 `toml:"tls_listen_addr,omitempty" json:"tls_listen_addr"`
	SocketPath             string                 `toml:"socket_path,omitempty" json:"socket_path"`
	VirtualStorages        []*VirtualStorage      `toml:"virtual_storage,omitempty" json:"virtual_storage"`
	Logging                log.Config             `toml:"logging,omitempty" json:"logging"`
	Sentry                 sentry.Config          `toml:"sentry,omitempty" json:"sentry"`
	PrometheusListenAddr   string                 `toml:"prometheus_listen_addr,omitempty" json:"prometheus_listen_addr"`
	Prometheus             prometheus.Config      `toml:"prometheus,omitempty" json:"prometheus"`
	Auth                   auth.Config            `toml:"auth,omitempty" json:"auth"`
	TLS                    config.TLS             `toml:"tls,omitempty" json:"tls"`
	DB                     `toml:"database,omitempty" json:"database"`
	Failover               Failover            `toml:"failover,omitempty" json:"failover"`
	MemoryQueueEnabled     bool                `toml:"memory_queue_enabled,omitempty" json:"memory_queue_enabled"`
	GracefulStopTimeout    duration.Duration   `toml:"graceful_stop_timeout,omitempty" json:"graceful_stop_timeout"`
	RepositoriesCleanup    RepositoriesCleanup `toml:"repositories_cleanup,omitempty" json:"repositories_cleanup"`
	Yamux                  Yamux               `toml:"yamux,omitempty" json:"yamux"`
}

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

	SessionPooled DBConnection `toml:"session_pooled,omitempty" json:"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,omitempty" json:"host_no_proxy"`
	PortNoProxy int    `toml:"port_no_proxy,omitempty" json:"port_no_proxy"`
}

DB holds database configuration data.

type DBConnection

type DBConnection struct {
	Host        string `toml:"host,omitempty" json:"host"`
	Port        int    `toml:"port,omitempty" json:"port"`
	User        string `toml:"user,omitempty" json:"user"`
	Password    string `toml:"password,omitempty" json:"password"`
	DBName      string `toml:"dbname,omitempty" json:"dbname"`
	SSLMode     string `toml:"sslmode,omitempty" json:"sslmode"`
	SSLCert     string `toml:"sslcert,omitempty" json:"sslcert"`
	SSLKey      string `toml:"sslkey,omitempty" json:"sslkey"`
	SSLRootCert string `toml:"sslrootcert,omitempty" json:"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 is a trigger used to check if failover is enabled or not.
	Enabled bool `toml:"enabled,omitempty" json:"enabled"`
	// ElectionStrategy is the strategy to use for electing primaries nodes.
	ElectionStrategy         ElectionStrategy  `toml:"election_strategy,omitempty" json:"election_strategy"`
	ErrorThresholdWindow     duration.Duration `toml:"error_threshold_window,omitempty" json:"error_threshold_window"`
	WriteErrorThresholdCount uint32            `toml:"write_error_threshold_count,omitempty" json:"write_error_threshold_count"`
	ReadErrorThresholdCount  uint32            `toml:"read_error_threshold_count,omitempty" json:"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 duration.Duration `toml:"bootstrap_interval,omitempty" json:"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 duration.Duration `toml:"monitor_interval,omitempty" json:"monitor_interval"`
}

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" json:"storage"`
	Address string `toml:"address,omitempty" json:"address"`
	Token   string `toml:"token,omitempty" json:"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

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" json:"scheduling_interval"`
	// HistogramBuckets configures the reconciliation scheduling duration histogram's buckets.
	HistogramBuckets []float64 `toml:"histogram_buckets,omitempty" json:"histogram_buckets"`
}

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" json:"batch_size"`
	// 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" json:"parallel_storage_processing_workers"`
}

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" json:"check_interval"`
	// RunInterval: the check runs if the previous operation was done at least RunInterval before.
	RunInterval duration.Duration `toml:"run_interval,omitempty" json:"run_interval"`
	// RepositoriesInBatch is the number of repositories to pass as a batch for processing.
	RepositoriesInBatch uint `toml:"repositories_in_batch,omitempty" json:"repositories_in_batch"`
}

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" json:"name"`
	Nodes []*Node `toml:"node,omitempty" json:"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,omitempty" json:"default_replication_factor"`
}

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" json:"maximum_stream_window_size_bytes"`
	// AcceptBacklog sets the maximum number of stream openings in-flight before further openings
	// block.
	AcceptBacklog uint `toml:"accept_backlog,omitempty" json:"accept_backlog"`
}

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