dmutex

package
v0.0.0-...-0b61f1f Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultUniqueField = "key"
	DefaultTTLField    = "created_at"
)

Variables

View Source
var (
	ErrMutexIndexNotExist = errors.New("unique index or ttl index not exists")
	ErrParamsIsNil        = errors.New("params cannot be nil")
	ErrDuplicateKey       = errors.New("duplicate key error")
	ErrNotFoundKey        = errors.New("key does not exist")
)

Functions

func EnsureMongoDBMutexIndex

func EnsureMongoDBMutexIndex(
	c *mgo.Collection,
	uniqueField string,
	ttlField string,
	expireAfter time.Duration,
) error

EnsureMongoDBMutexIndex Ensure the index required by mutex exists

func NewMongoDBImpl

func NewMongoDBImpl(c *mgo.Collection, cfg *MutexMongoDBImplConfig) (*mutexMongoDBImpl, error)

NewMongoDBImpl creates a new mutex, Implemented by mongodb.

Types

type Locker

type Locker interface {
	Lock(string) error
	Unlock(string) error
}

type MutexMongoDBImplConfig

type MutexMongoDBImplConfig struct {
	TTLField    string
	UniqueField string
}

Jump to

Keyboard shortcuts

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