Documentation
¶
Overview ¶
Package embed provides an embeddable runtime for sqlq workers.
It enables users to implement a long-living, background service that can either be embedded in the same application or packaged as a separate executable.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrWorkerClosed = errors.New("sqlq: worker closed")
ErrWorkerClosed indicates that the worker has already been closed
var ErrWorkerRunning = errors.New("sqlq: worker running")
ErrWorkerRunning indicated that the worker has already started running, and no further changes can be made
Functions ¶
This section is empty.
Types ¶
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker is the main service where you'd register handlers for different job types, and it'd (at configured time intervals) pull jobs from the queue to execute.
A worker also owns and manages lifecycle of other critical services, like, reaper and janitor. It provides an execution environment for a job, and manages critical things such as log shipping, keep-alive etc.
func NewWorker ¶
func NewWorker(db *sql.DB, config WorkerConfig) (*Worker, error)
NewWorker creates a new instance of worker, configures it using the provided options and return it.
type WorkerConfig ¶
type WorkerConfig struct { // Maximum number of concurrent processing of tasks this worker should handle. // // If set to a zero or negative value, NewWorker will overwrite the value // to the number of CPUs usable by the current process. Concurrency int // List of queues from where the worker will retrieve jobs. // User must provide one or more queues to watch. Queues []sqlq.Queue }