mongodb

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	ID               string `bson:"_id"`
	Topic            string
	State            string
	Args             *string
	Rank             int
	Priority         int64
	Retry            int
	MaxRetry         int    `bson:"max_retry"`
	CorrelationGroup string `bson:"correlation_group"`
	CorrelationID    string `bson:"correlation_id"`
	Created          int64
	Started          int64
	Completed        int64
	LastMod          int64 `bson:"last_mod"`
}

func (*Job) ToJob

func (j *Job) ToJob() (*jobqueue.Job, error)

type Store

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

Store represents a MongoDB-based storage backend.

func NewStore

func NewStore(mongodbURL string, options ...StoreOption) (*Store, error)

NewStore creates a new MongoDB-based storage backend.

func (*Store) Close

func (s *Store) Close() error

Close the MongoDB store.

func (*Store) Create

func (s *Store) Create(ctx context.Context, job *jobqueue.Job) error

Create adds a new job to the store.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, job *jobqueue.Job) error

Delete removes a job from the store.

func (*Store) List

func (s *Store) List(ctx context.Context, request *jobqueue.ListRequest) (*jobqueue.ListResponse, error)

List returns a list of all jobs stored in the data store.

func (*Store) Lookup

func (s *Store) Lookup(ctx context.Context, id string) (*jobqueue.Job, error)

Lookup retrieves a single job in the store by its identifier.

func (*Store) LookupByCorrelationID

func (s *Store) LookupByCorrelationID(ctx context.Context, correlationID string) ([]*jobqueue.Job, error)

LookupByCorrelationID returns the details of jobs by their correlation identifier. If no such job could be found, an empty array is returned.

func (*Store) Next

func (s *Store) Next() (*jobqueue.Job, error)

Next picks the next job to execute, or nil if no executable job is available.

func (*Store) Start

func (s *Store) Start(b jobqueue.StartupBehaviour) error

Start is called when the manager starts up. We ensure that stale jobs are marked as failed so that we have place for new jobs.

func (*Store) Stats

func (s *Store) Stats(ctx context.Context, req *jobqueue.StatsRequest) (*jobqueue.Stats, error)

Stats returns statistics about the jobs in the store.

func (*Store) Update

func (s *Store) Update(ctx context.Context, job *jobqueue.Job) error

Update updates the job in the store.

type StoreOption

type StoreOption func(*Store)

StoreOption is an options provider for Store.

func SetCollectionName

func SetCollectionName(collectionName string) StoreOption

SetCollectionName overrides the default collection name.

Jump to

Keyboard shortcuts

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