Documentation ¶
Index ¶
- Variables
- type JobStore
- func (m *JobStore) AcquireJobLock(ctx context.Context, jobID string) (lockID string, err error)
- func (m *JobStore) Checker(ctx context.Context, state *healthcheck.CheckState) error
- func (m *JobStore) Close(ctx context.Context) error
- func (m *JobStore) CreateJob(ctx context.Context, id string) (models.Job, error)
- func (m *JobStore) CreateTask(ctx context.Context, jobID string, taskName string, numDocuments int) (models.Task, error)
- func (m *JobStore) GetJob(ctx context.Context, id string) (models.Job, error)
- func (m *JobStore) GetJobs(ctx context.Context, offsetParam string, limitParam string) (models.Jobs, error)
- func (m *JobStore) GetTask(ctx context.Context, jobID string, taskName string) (models.Task, error)
- func (m *JobStore) Init(ctx context.Context, cfg *config.Config) (err error)
- func (m *JobStore) PutNumberOfTasks(ctx context.Context, id string, numTasks int) error
- func (m *JobStore) UnlockJob(lockID string) error
- func (m *JobStore) UpdateJob(updates bson.M, s *mgo.Session, id string) error
- func (m *JobStore) UpsertTask(jobID, taskName string, task models.Task) error
Constants ¶
This section is empty.
Variables ¶
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 { Session *mgo.Session URI string Database string JobsCollection string LocksCollection string TasksCollection 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 ¶
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) CreateJob ¶
CreateJob creates a new job, with the given id, in the collection, and assigns default values to its attributes
func (*JobStore) CreateTask ¶ added in v0.9.0
func (m *JobStore) CreateTask(ctx context.Context, jobID string, taskName string, numDocuments int) (models.Task, error)
CreateTask creates a new task, for the given API and job ID, in the collection, and assigns default values to its attributes
func (*JobStore) GetJob ¶
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, offsetParam string, limitParam string) (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
GetTask retrieves the details of a particular task, from the collection, specified by its task name and associated job id
func (*JobStore) Init ¶
Init creates a new mgo.Session with a strong consistency and a write mode of "majority".
func (*JobStore) PutNumberOfTasks ¶ added in v0.6.0
PutNumberOfTasks updates the number_of_tasks in a particular job, from the collection, specified by its id
func (*JobStore) UnlockJob ¶
UnlockJob releases an exclusive mongoDB lock for the provided lockId (if it exists)