distributedlockcfg

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RedisProvider selects the redis-backed distributedlock.Locker implementation.
	RedisProvider = "redis"
	// PostgresProvider selects the postgres-backed distributedlock.Locker implementation.
	PostgresProvider = "postgres"
	// MemoryProvider selects the in-memory distributedlock.Locker implementation.
	MemoryProvider = "memory"
	// NoopProvider selects the no-op distributedlock.Locker implementation.
	NoopProvider = "noop"
)

Variables

This section is empty.

Functions

func ProvideLocker

func ProvideLocker(
	ctx context.Context,
	cfg *Config,
	logger logging.Logger,
	tracerProvider tracing.TracerProvider,
	metricsProvider metrics.Provider,
	db database.Client,
) (distributedlock.Locker, error)

ProvideLocker constructs a distributedlock.Locker for the configured provider. The db argument is required only when Provider is PostgresProvider; pass nil otherwise. Unknown or empty providers fall back to the noop locker.

Types

type Config

type Config struct {
	Redis          *redislock.Config         `env:"init"     envPrefix:"REDIS_"            json:"redis"`
	Postgres       *pglock.Config            `env:"init"     envPrefix:"POSTGRES_"         json:"postgres"`
	Provider       string                    `env:"PROVIDER" json:"provider"`
	CircuitBreaker circuitbreakingcfg.Config `env:"init"     envPrefix:"CIRCUIT_BREAKING_" json:"circuitBreakerConfig"`
	// contains filtered or unexported fields
}

Config dispatches to a distributedlock provider implementation.

func (*Config) ValidateWithContext

func (cfg *Config) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates a Config struct. Empty Provider is acceptable and resolves to the noop locker — matching the dispatch convention used elsewhere in platform.

Jump to

Keyboard shortcuts

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