mongodb

package
v1.11.3 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_DATABASE = "fleetlock"

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoDBBackend

type MongoDBBackend struct {
	// contains filtered or unexported fields
}

func NewMongoDBBackend

func NewMongoDBBackend(cfg MongoDBConfig) (*MongoDBBackend, error)

func (*MongoDBBackend) Close

func (m *MongoDBBackend) Close() error

Calls all necessary finalization if necessary

func (*MongoDBBackend) GetLocks

func (m *MongoDBBackend) GetLocks(group string) (int, error)

Returns the current number of locks for the given group

func (*MongoDBBackend) GetStaleLocks

func (m *MongoDBBackend) GetStaleLocks(ts time.Duration) ([]types.Lock, error)

Return all locks older than x

func (*MongoDBBackend) HasLock

func (m *MongoDBBackend) HasLock(group string, id string) (bool, error)

Check if a given id already has a lock for this group

func (*MongoDBBackend) Release

func (m *MongoDBBackend) Release(group string, id string) error

Release the lock currently held by the id. Does not fail when no lock is held.

func (*MongoDBBackend) Reserve

func (m *MongoDBBackend) Reserve(group string, id string) error

Reserve a lock for the given group. Returns true if the lock is successfully reserved, even if the lock is already held by the specific id

type MongoDBConfig

type MongoDBConfig struct {
	URL      string `yaml:"url,omitempty"`
	Database string `yaml:"database,omitempty"`
}

type MongoLock

type MongoLock struct {
	ID      string    `bson:"_id,omitempty"`
	Created time.Time `bson:"created,omitempty"`
}

Jump to

Keyboard shortcuts

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