mdbq

package
v0.0.0-...-bd4921e Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeDBQueueManager

func MakeDBQueueManager(ctx context.Context, opts DBQueueManagerOptions, client *mongo.Client) (management.Manager, error)

MakeDBQueueManager make it possible to produce a queue manager with an existing database Connection. This operations runs the "ping" command and and will return an error if there is no session or no active server.

func NewDBQueueManager

func NewDBQueueManager(ctx context.Context, opts DBQueueManagerOptions) (management.Manager, error)

NewDBQueueManager produces a queue manager for (remote) queues that persist jobs in MongoDB. This implementation does not interact with the queue directly, and manages by interacting with the database directly.

func NewMongoDBQueue

func NewMongoDBQueue(ctx context.Context, opts MongoDBQueueCreationOptions) (amboy.Queue, error)

NewMongoDBQueue builds a new queue that persists jobs to a MongoDB instance. These queues allow workers running in multiple processes to service shared workloads in multiple processes.

func NewMongoDBQueueGroup

func NewMongoDBQueueGroup(ctx context.Context, opts MongoDBQueueGroupOptions, client *mongo.Client, mdbopts MongoDBOptions) (amboy.QueueGroup, error)

NewMongoDBQueueGroup constructs a new remote queue group. If ttl is 0, the queues will not be TTLed except when the client explicitly calls Prune.

The MongoDBRemoteQueue group creats a new collection for every queue, unlike the other remote queue group implementations. This is probably most viable for lower volume workloads; however, the caching mechanism may be more responsive in some situations.

func NewMongoDBSingleQueueGroup

func NewMongoDBSingleQueueGroup(ctx context.Context, opts MongoDBQueueGroupOptions, client *mongo.Client, mdbopts MongoDBOptions) (amboy.QueueGroup, error)

NewMongoDBSingleQueueGroup constructs a new remote queue group. If ttl is 0, the queues will not be TTLed except when the client explicitly calls Prune.

Types

type DBQueueManagerOptions

type DBQueueManagerOptions struct {
	Name        string
	Group       string
	SingleGroup bool
	ByGroups    bool
	Options     MongoDBOptions
}

DBQueueManagerOptions describes the arguments to the operations to construct queue managers, and accommodates both group-backed queues and conventional queues.

func (*DBQueueManagerOptions) Validate

func (o *DBQueueManagerOptions) Validate() error

Validate checks the state of the manager configuration, preventing logically invalid options.

type MongoDBOptions

type MongoDBOptions struct {
	URI                      string
	DB                       string
	GroupName                string
	UseGroups                bool
	Priority                 bool
	CheckWaitUntil           bool
	CheckDispatchBy          bool
	SkipQueueIndexBuilds     bool
	SkipReportingIndexBuilds bool
	Marshler                 registry.Marshaler
	Unmarshaler              registry.Unmarshaler
	WaitInterval             time.Duration
	// TTL sets the number of seconds for a TTL index on the "info.created"
	// field. If set to zero, the TTL index will not be created and
	// and documents may live forever in the database.
	TTL time.Duration
	// LockTimeout overrides the default job lock timeout if set.
	LockTimeout time.Duration
}

MongoDBOptions is a struct passed to the NewMongo constructor to communicate mgoDriver specific settings about the driver's behavior and operation.

func DefaultMongoDBOptions

func DefaultMongoDBOptions() MongoDBOptions

DefaultMongoDBOptions constructs a new options object with default values: connecting to a MongoDB instance on localhost, using the "amboy" database, and *not* using priority ordering of jobs.

func (*MongoDBOptions) Validate

func (opts *MongoDBOptions) Validate() error

Validate validates that the required options are given and sets fields that are unspecified and have a default value.

type MongoDBQueueCreationOptions

type MongoDBQueueCreationOptions struct {
	Size    int
	Name    string
	Ordered bool
	MDB     MongoDBOptions
	Client  *mongo.Client
}

MongoDBQueueCreationOptions describes the options passed to the remote queue, that store jobs in a remote persistence layer to support distributed systems of workers.

func (*MongoDBQueueCreationOptions) Validate

func (opts *MongoDBQueueCreationOptions) Validate() error

Validate ensure that the arguments defined are valid.

type MongoDBQueueGroupOptions

type MongoDBQueueGroupOptions struct {
	// Prefix is a string prepended to the queue collections.
	Prefix string

	// Abortable controls if the queue will use an abortable pool
	// imlementation. The Ordered option controls if an
	// order-respecting queue will be created, while default
	// workers sets the default number of workers new queues will
	// have if the WorkerPoolSize function is not set.
	Abortable      bool
	Ordered        bool
	DefaultWorkers int

	// WorkerPoolSize determines how many works will be allocated
	// to each queue, based on the queue ID passed to it.
	WorkerPoolSize func(string) int

	// PruneFrequency is how often Prune runs by default.
	PruneFrequency time.Duration

	// BackgroundCreateFrequency is how often the background queue
	// creation runs, in the case that queues may be created in
	// the background without
	BackgroundCreateFrequency time.Duration

	// TTL is how old the oldest task in the queue must be for the collection to be pruned.
	TTL time.Duration
}

MongoDBQueueGroupOptions describe options passed to NewRemoteQueueGroup.

Jump to

Keyboard shortcuts

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