distributedlockcfg

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: AGPL-3.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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