config

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KeyClusterUUID is the key for the cluster UUID in the configuration database.
	KeyClusterUUID = "cluster_uuid"
	// KeySecretKey is the key for the secret key in the configuration database.
	KeySecretKey = "secret_key"
	// KeyCDCEnabled is the key for CDC enabled flag in the configuration database.
	KeyCDCEnabled = "cdc_enabled"
	// KeyCDCMin is the key for CDC minimum chunk size in the configuration database.
	KeyCDCMin = "cdc_min"
	// KeyCDCAvg is the key for CDC average chunk size in the configuration database.
	KeyCDCAvg = "cdc_avg"
	// KeyCDCMax is the key for CDC maximum chunk size in the configuration database.
	KeyCDCMax = "cdc_max"
)

Variables

View Source
var (
	// ErrConfigNotFound is returned if no config with this key was found.
	ErrConfigNotFound = errors.New("no config was found for this key")

	// ErrCDCDisabledAfterEnabled is returned when attempting to disable CDC after being enabled.
	ErrCDCDisabledAfterEnabled = errors.New(
		"CDC cannot be disabled after being enabled; existing chunked NARs would not be reconstructed",
	)
	// ErrCDCConfigMismatch is returned when CDC configuration values differ from stored values.
	ErrCDCConfigMismatch = errors.New(
		"CDC config changed; different chunk sizes create new chunks without reusing old ones, causing storage duplication",
	)
	// ErrCDCInvalidChunkSizes is returned when CDC chunk sizes are zero or invalid.
	ErrCDCInvalidChunkSizes = errors.New(
		"CDC chunk sizes must be non-zero when CDC is enabled",
	)
)

Functions

This section is empty.

Types

type Config

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

Config provides access to the persistent configuration stored in the database. It uses an RWLocker to ensure thread-safe access to configuration keys.

func New

func New(db database.Querier, rwLocker lock.RWLocker) *Config

New returns a new Config instance.

func (*Config) GetCDCAvg added in v0.9.2

func (c *Config) GetCDCAvg(ctx context.Context) (string, error)

GetCDCAvg returns the CDC average chunk size from the configuration.

func (*Config) GetCDCEnabled added in v0.9.2

func (c *Config) GetCDCEnabled(ctx context.Context) (string, error)

GetCDCEnabled returns the CDC enabled flag from the configuration.

func (*Config) GetCDCMax added in v0.9.2

func (c *Config) GetCDCMax(ctx context.Context) (string, error)

GetCDCMax returns the CDC maximum chunk size from the configuration.

func (*Config) GetCDCMin added in v0.9.2

func (c *Config) GetCDCMin(ctx context.Context) (string, error)

GetCDCMin returns the CDC minimum chunk size from the configuration.

func (*Config) GetClusterUUID

func (c *Config) GetClusterUUID(ctx context.Context) (string, error)

GetClusterUUID returns the cluster UUID from the configuration.

func (*Config) GetSecretKey added in v0.7.0

func (c *Config) GetSecretKey(ctx context.Context) (string, error)

GetSecretKey returns the secret key from the configuration.

func (*Config) SetCDCAvg added in v0.9.2

func (c *Config) SetCDCAvg(ctx context.Context, value string) error

SetCDCAvg stores the CDC average chunk size in the configuration.

func (*Config) SetCDCEnabled added in v0.9.2

func (c *Config) SetCDCEnabled(ctx context.Context, value string) error

SetCDCEnabled stores the CDC enabled flag in the configuration.

func (*Config) SetCDCMax added in v0.9.2

func (c *Config) SetCDCMax(ctx context.Context, value string) error

SetCDCMax stores the CDC maximum chunk size in the configuration.

func (*Config) SetCDCMin added in v0.9.2

func (c *Config) SetCDCMin(ctx context.Context, value string) error

SetCDCMin stores the CDC minimum chunk size in the configuration.

func (*Config) SetClusterUUID

func (c *Config) SetClusterUUID(ctx context.Context, value string) error

SetClusterUUID stores the cluster UUID in the configuration.

func (*Config) SetSecretKey added in v0.7.0

func (c *Config) SetSecretKey(ctx context.Context, value string) error

SetSecretKey stores the secret key in the configuration.

func (*Config) ValidateOrStoreCDCConfig added in v0.9.2

func (c *Config) ValidateOrStoreCDCConfig(
	ctx context.Context,
	enabled bool,
	minSize, avgSize, maxSize uint32,
) error

ValidateOrStoreCDCConfig validates CDC configuration against stored values or stores them if not yet configured. If CDC is disabled and no config exists, returns nil (no-op). If CDC is enabled and no config exists, stores all 4 values. If config exists, validates that enabled flag matches and all values are identical. If CDC was previously enabled (config exists) but now disabled, returns an error.

Jump to

Keyboard shortcuts

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