mongodb_lock

package module
v0.0.0-...-33994ad Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: MIT Imports: 7 Imported by: 0

README

gocron-mongodb-lock

Documentation

Index

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

type MongoDBLockerOptions

type MongoDBLockerOptions struct {
	ExpireAfter  time.Duration
	KeyField     string
	TTLField     string
	UnlockAlways bool
}

Jump to

Keyboard shortcuts

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