Documentation
¶
Index ¶
- func MutexIsErrNotObtained(err error) bool
- type Mutex
- type MutexOption
- func MutexOptionDetailedLockMetadata() MutexOption
- func MutexOptionLockFor(d time.Duration) MutexOption
- func MutexOptionLockMetadata(metadata string) MutexOption
- func MutexOptionLockToken(token string) MutexOption
- func MutexOptionNoRetry() MutexOption
- func MutexOptionRetryExponentialBackoff(min, max time.Duration) MutexOption
- func MutexOptionRetryFor(d time.Duration) MutexOption
- func MutexOptionRetryForExponentialBackoff(tries int, min, max time.Duration) MutexOption
- func MutexOptionRetryForLinearBackoff(tries int, backoff time.Duration) MutexOption
- func MutexOptionRetryLinearBackoff(backoff time.Duration) MutexOption
- type R
- func MustApplyTestConfig(cfg config.C) (config.C, R)
- func New(ctx context.Context, c config.C, logger *slog.Logger) (R, error)
- func NewForRoot(ctx context.Context, root *config.Root, logger *slog.Logger) (R, error)
- func NewMiniredis(redisConfig *config.RedisMiniredis, secretKey config.KeyData, ...) (R, error)
- func NewRedis(ctx context.Context, redisConfig *config.RedisReal, secretKey config.KeyData, ...) (R, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MutexIsErrNotObtained ¶
Types ¶
type MutexOption ¶
type MutexOption func(m *mutex)
func MutexOptionDetailedLockMetadata ¶
func MutexOptionDetailedLockMetadata() MutexOption
MutexOptionDetailedLockMetadata applies json metadata to the lock about the host, process, etc that acquired the lock
func MutexOptionLockFor ¶
func MutexOptionLockFor(d time.Duration) MutexOption
MutexOptionLockFor sets the initial lock duration for the mutex. If unspecified, the default initial lock duration is one minute. This duration can be extended by calling Extend(...) on the mutex once it's acquired.
func MutexOptionLockMetadata ¶
func MutexOptionLockMetadata(metadata string) MutexOption
MutexOptionLockMetadata appends additional data to the value used to obtain the lock in redis for debugging purposes.
func MutexOptionLockToken ¶
func MutexOptionLockToken(token string) MutexOption
MutexOptionLockToken sets the token value used with the key when obtaining the lock in Redis. Setting this value explicitly allows you to control how the lock is inspectable in the redis data. By default, a random value is used. If you set this value, you need to be careful that you understand how you expect the lock to behave across processes and within the same process. For debugging, setting metadata as an appended value on the lock value may be a better option.
func MutexOptionNoRetry ¶
func MutexOptionNoRetry() MutexOption
func MutexOptionRetryExponentialBackoff ¶
func MutexOptionRetryExponentialBackoff(min, max time.Duration) MutexOption
func MutexOptionRetryFor ¶
func MutexOptionRetryFor(d time.Duration) MutexOption
MutexOptionRetryFor sets how long the mutex will attempt to retry for a lock. This must be combined with a retry strategy or the default MutexOptionNoRetry() will prevent retries.
func MutexOptionRetryForExponentialBackoff ¶
func MutexOptionRetryForExponentialBackoff(tries int, min, max time.Duration) MutexOption
func MutexOptionRetryForLinearBackoff ¶
func MutexOptionRetryForLinearBackoff(tries int, backoff time.Duration) MutexOption
func MutexOptionRetryLinearBackoff ¶
func MutexOptionRetryLinearBackoff(backoff time.Duration) MutexOption
type R ¶
type R interface { Ping(ctx context.Context) bool Close() error Client() *redis.Client NewMutex(key string, options ...MutexOption) Mutex }
func New ¶
New creates a new database connection from the specified configuration. The type of the database returned will be determined by the configuration.
func NewForRoot ¶
NewForRoot creates a new database connection from the specified configuration. The type of the database returned will be determined by the configuration. Same as NewConnection.
func NewMiniredis ¶
func NewMiniredis(redisConfig *config.RedisMiniredis, secretKey config.KeyData, logger *slog.Logger) (R, error)
NewMiniredis creates a new database connection to a SQLite database.
Parameters: - redisConfig: the configuration for the SQLite database - secretKey: the AES key used to secure cursors
func NewRedis ¶
func NewRedis(ctx context.Context, redisConfig *config.RedisReal, secretKey config.KeyData, logger *slog.Logger) (R, error)
NewRedis creates a new redis connection to a real redis instance.
Parameters: - redisConfig: the configuration for the Redis instance - secretKey: the AES key used to secure cursors