mongo

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JobStore

type JobStore struct {
	Session         *mgo.Session
	URI             string
	Database        string
	Collection      string
	LocksCollection string
	// contains filtered or unexported fields
}

JobStore is a type that contains an implementation of the MongoJobStorer interface, which can be used for creating and getting Job resources. It also represents a simplistic MongoDB configuration, with session, health and lock clients

func (*JobStore) AcquireJobLock

func (m *JobStore) AcquireJobLock(ctx context.Context, jobID string) (lockID string, err error)

AcquireJobLock tries to lock the provided jobID. If the job is already locked, this function will block until it's released, at which point we acquire the lock and return.

func (*JobStore) Checker

func (m *JobStore) Checker(ctx context.Context, state *healthcheck.CheckState) error

Checker is called by the healthcheck library to check the health state of this mongoDB instance

func (*JobStore) Close

func (m *JobStore) Close(ctx context.Context) error

Close closes the mongo session and returns any error

func (*JobStore) CreateJob

func (m *JobStore) CreateJob(ctx context.Context, id string) (job models.Job, err error)

CreateJob creates a new job, with the given id, in the collection, and assigns default values to its attributes

func (*JobStore) GetJob

func (m *JobStore) GetJob(ctx context.Context, id string) (models.Job, error)

GetJob retrieves the details of a particular job, from the collection, specified by its id

func (*JobStore) GetJobs

func (m *JobStore) GetJobs(ctx context.Context) (models.Jobs, error)

GetJobs retrieves all the jobs, from the collection, and lists them in order of last_updated

func (*JobStore) Init

func (m *JobStore) Init(ctx context.Context) (err error)

Init creates a new mgo.Session with a strong consistency and a write mode of "majority".

func (*JobStore) UnlockJob

func (m *JobStore) UnlockJob(lockID string) error

UnlockJob releases an exclusive mongoDB lock for the provided lockId (if it exists)

Jump to

Keyboard shortcuts

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