Documentation
¶
Index ¶
- Constants
- Variables
- func NewMongoDBLocker(ctx context.Context, c *mongo.Collection, opts ...MongoDBLockerOption) (*mongoDBLocker, error)
- func NewMongoDBLockerAlways(ctx context.Context, c *mongo.Collection, opts ...MongoDBLockerOption) (*mongoDBLocker, error)
- type MongoDBLockerOption
- type MongoDBLockerOptions
Constants ¶
View Source
const ( DefaultKeyField = "key" DefaultTTLField = "created_at" )
Variables ¶
View Source
var ( ErrLockIndexCouldNotCreate = errors.New("could not create indices on either the unique or ttl field(s)") ErrParamIsNil = errors.New("param(s) cannot be nil") ErrDuplicateKey = errors.New("duplicate key error") ErrNotFoundKey = errors.New("key does not exist") ErrCouldNotUnlock = errors.New("could not unlock") )
Functions ¶
func NewMongoDBLocker ¶
func NewMongoDBLocker(ctx context.Context, c *mongo.Collection, opts ...MongoDBLockerOption) (*mongoDBLocker, error)
NewMongoDBLockerAlways creates a new mongodb-backed distributed locker.
func NewMongoDBLockerAlways ¶
func NewMongoDBLockerAlways(ctx context.Context, c *mongo.Collection, opts ...MongoDBLockerOption) (*mongoDBLocker, error)
NewMongoDBLockerAlways creates a new mongodb-backed distributed locker, even when pinging fails.
Types ¶
type MongoDBLockerOption ¶
type MongoDBLockerOption func(*MongoDBLockerOptions)
func WithMongoDBLockerExpireAfter ¶
func WithMongoDBLockerExpireAfter(expireAfter time.Duration) MongoDBLockerOption
func WithMongoDBLockerKeyField ¶
func WithMongoDBLockerKeyField(keyField string) MongoDBLockerOption
func WithMongoDBLockerTTLField ¶
func WithMongoDBLockerTTLField(ttlField string) MongoDBLockerOption
func WithMongoDBLockerUnlockAlways ¶
func WithMongoDBLockerUnlockAlways() MongoDBLockerOption
Click to show internal directories.
Click to hide internal directories.