mongo

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrJobNotFound           = errors.New("the job id could not be found in the jobs collection")
	ErrEmptyIDProvided       = errors.New("id must not be an empty string")
	ErrDuplicateIDProvided   = errors.New("id must be unique")
	ErrExistingJobInProgress = errors.New("there is an existing job currently in progress")
	ErrTaskNotFound          = errors.New("the task name could not be found for the job id in the search database")
	ErrEmptyTaskNameProvided = errors.New("task name must not be an empty string")
)

A list of error messages for Mongo

Functions

This section is empty.

Types

type JobStore

type JobStore struct {
	config.MongoConfig

	Connection   *mongodriver.MongoConnection
	HealthClient *mongohealth.CheckMongoClient
	LockClient   *mongolock.Lock
}

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) CheckInProgressJob added in v0.21.0

func (m *JobStore) CheckInProgressJob(ctx context.Context, cfg *config.Config) error

CheckInProgressJob checks if a new reindex job can be created depending on if a reindex job is currently in progress between cfg.MaxReindexJobRuntime before now and now It returns an error if a reindex job already exists which is in_progress state

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 disconnects the mongo session

func (*JobStore) CreateJob

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

CreateJob creates a new job, with the given search index name, 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, option Options) (*models.Jobs, error)

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

func (*JobStore) GetTask added in v0.10.0

func (m *JobStore) GetTask(ctx context.Context, jobID, taskName string) (*models.Task, error)

GetTask retrieves the details of a particular task, from the collection, specified by its task name and associated job id

func (*JobStore) GetTasks added in v0.12.0

func (m *JobStore) GetTasks(ctx context.Context, jobID string, options Options) (*models.Tasks, error)

GetTasks retrieves all the tasks, from the collection, and lists them in order of last_updated

func (*JobStore) Init

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

Init returns an initialised Mongo object encapsulating a connection to the mongo server/cluster with the given configuration, a health client to check the health of the mongo server/cluster, and a lock client

func (*JobStore) UnlockJob

func (m *JobStore) UnlockJob(ctx context.Context, lockID string)

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

func (*JobStore) UpdateJob added in v0.6.0

func (m *JobStore) UpdateJob(ctx context.Context, id string, updates bson.M) error

UpdateJob updates a particular job with the values passed in through the 'updates' input parameter

func (*JobStore) UpsertTask added in v0.9.0

func (m *JobStore) UpsertTask(ctx context.Context, jobID, taskName string, task models.Task) error

UpsertTask creates a new task document or overwrites an existing one

type Options added in v0.19.0

type Options struct {
	Offset int
	Limit  int
}

Options contains information for pagination which includes offset and limit

Jump to

Keyboard shortcuts

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