Documentation
¶
Overview ¶
Package tasking - an embeddable Go library for running asynchronous background tasks and multi-step DAG workflows
Index ¶
- func DefineTaskQueueForWorkflowStep(requestQueue string, workers int, requestBufferLen int, dbClient db.Client, ...) (models.TaskQueueConfig, error)
- func NewNotificationProducer(parentCtx context.Context, producerConfig models.NotificationProducerConfig, ...) (notify.Producer, error)
- func NewPersistenceClient(dialector gorm.Dialector, dbLogLevel logger.LogLevel) (db.Client, error)
- func NewTaskClient(parentCtx context.Context, clientName string, taskCreator string, ...) (task.Client, error)
- func NewTaskScheduler(parentCtx context.Context, schedulerConfig models.TaskSchedulerConfig, ...) (task.Scheduler, error)
- func NewTaskWorkerReceiver(parentCtx context.Context, receiverConfig models.TaskReceiverConfig, ...) (task.Receiver, error)
- func NewWorkflowClient(parentCtx context.Context, clientName string, workflowCreator string, ...) (workflow.Client, error)
- func NewWorkflowScheduler(parentCtx context.Context, workflowConfig models.WorkflowSchedulerConfig, ...) (workflow.Scheduler, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefineTaskQueueForWorkflowStep ¶
func DefineTaskQueueForWorkflowStep( requestQueue string, workers int, requestBufferLen int, dbClient db.Client, workflowStepHandlers map[string]models.WorkflowStepProcessor, ) (models.TaskQueueConfig, error)
DefineTaskQueueForWorkflowStep helper function to define a Task Engine queue config for executing workflow steps through the Task Engine.
Combine the returned config with the rest of your queue configs, and give the combined set to *both* the task receiver (models.TaskReceiverConfig) and the task scheduler (models.TaskSchedulerConfig): the receiver needs it to run step tasks, and the scheduler needs it to know which queue to dispatch them to. Giving it to the receiver alone leaves step tasks defined but never routed, so workflows stall with nothing reported.
Do not also declare models.WorkflowExecutionTaskName in a queue of your own. Task names must be unique across a config, so the duplicate is rejected when the component is constructed.
@param requestQueue string - task queue name for sending workflow step execution requests
@param workers int - number of workers to process tasks from the queue in parallel
@param requestBufferLen int - number of requests a task receiver can locally buffer for execution
@param dbClient db.Client - persistence client; see NewPersistenceClient
@param workflowStepHandlers map[string]models.WorkflowStepProcessor - step Type to processor
mapping the workflow step runner supports. Fixed at construction; must contain no nil
processors.
@returns new task engine queue config
func NewNotificationProducer ¶
func NewNotificationProducer( parentCtx context.Context, producerConfig models.NotificationProducerConfig, dbClient db.Client, redisClient goutilsRedis.Client, ) (notify.Producer, error)
NewNotificationProducer helper function to define a notification producer - the component which polls the audit log for un-broadcast events and publishes them over Redis pub/sub.
Set producerConfig.EmitCreator when running the Workflow Engine. The workflow scheduler learns a step's outcome by subscribing to the engine's creator channel, and the producer only publishes creator channels when that flag is set, so leaving it false strands every step in RUNNING until its deadline expires.
@param parentCtx context.Context - the parent execution context of the producer @param producerConfig models.NotificationProducerConfig - notification producer config @param dbClient db.Client - persistence client; see NewPersistenceClient @param redisClient goutilsRedis.Client - REDIS client @returns new notification producer
func NewPersistenceClient ¶
NewPersistenceClient helper function to define a tasking persistence client.
Define one client and pass it to every component in the process. A client owns a connection pool, and each component holds on to the one it is given for its lifetime, so building a client per component opens several pools against the same database to no purpose.
@param dbDialector gorm.Dialector - GORM dialector @param dbLogLevel logger.LogLevel - SQL log level @returns new persistence client
func NewTaskClient ¶
func NewTaskClient( parentCtx context.Context, clientName string, taskCreator string, clientConfig models.TaskClientConfig, dbClient db.Client, redisClient goutilsRedis.Client, ) (task.Client, error)
NewTaskClient helper function to define a Task Engine client
@param parentCtx context.Context - the parent execution context of the client @param clientName string - client name @param taskCreator string - task creator name. Bind tasks created by this client to this name @param clientConfig models.TaskClientConfig - task client config @param dbClient db.Client - persistence client; see NewPersistenceClient @param redisClient goutilsRedis.Client - REDIS client @returns new task client
func NewTaskScheduler ¶
func NewTaskScheduler( parentCtx context.Context, schedulerConfig models.TaskSchedulerConfig, dbClient db.Client, redisClient goutilsRedis.Client, onFatalCB models.OnFatalCB, ) (task.Scheduler, error)
NewTaskScheduler helper function to define a Task Engine worker scheduler
@param parentCtx context.Context - the parent execution context of the scheduler
@param schedulerConfig models.TaskSchedulerConfig - task scheduler config
@param dbClient db.Client - persistence client; see NewPersistenceClient
@param redisClient goutilsRedis.Client - REDIS client
@param onFatalCB models.OnFatalCB - when set, is invoked (at most once) when a queue-processing
goroutine hits an unrecoverable fault instead of terminating the process. reporter identifies
the faulting queue thread; err carries the cause (with code position in its chain); timestamp
is when it was detected. When nil, the default logs and calls log.Fatal, preserving prior
behavior. The goroutine exits after the callback runs.
@returns new task scheduler
func NewTaskWorkerReceiver ¶
func NewTaskWorkerReceiver( parentCtx context.Context, receiverConfig models.TaskReceiverConfig, dbClient db.Client, redisClient goutilsRedis.Client, onFatalCB models.OnFatalCB, ) (task.Receiver, error)
NewTaskWorkerReceiver helper function to define a Task Engine Worker request receiver
@param parentCtx context.Context - the parent execution context of the receiver
@param receiverConfig models.TaskReceiverConfig - task receiver config
@param dbClient db.Client - persistence client; see NewPersistenceClient
@param redisClient goutilsRedis.Client - REDIS client
@param onFatalCB models.OnFatalCB - when set, is invoked (at most once) when a queue-processing
goroutine hits an unrecoverable fault instead of terminating the process. reporter identifies
the faulting queue thread; err carries the cause (with code position in its chain); timestamp
is when it was detected. When nil, the default logs and calls log.Fatal, preserving prior
behavior. The goroutine exits after the callback runs.
@returns new task receiver
func NewWorkflowClient ¶
func NewWorkflowClient( parentCtx context.Context, clientName string, workflowCreator string, clientConfig models.WorkflowClientConfig, knownStepTypes []string, dbClient db.Client, redisClient goutilsRedis.Client, ) (workflow.Client, error)
NewWorkflowClient helper function to define a Workflow Engine client
knownStepTypes must list the same step Types the Step Runner was built with - the handler map given to DefineTaskQueueForWorkflowStep. DefineWorkflow rejects a workflow containing a step of any other Type up front, rather than letting it fail mid-run, so a Type missing here is refused at submission and a Type listed here without a matching handler fails when the step is executed.
@param parentCtx context.Context - the parent execution context of the client
@param clientName string - client name
@param workflowCreator string - workflow creator name. Bind workflows created by this client to
this name
@param clientConfig models.WorkflowClientConfig - workflow client config
@param knownStepTypes []string - the step Types with a registered handler. Must be non-empty
@param dbClient db.Client - persistence client; see NewPersistenceClient
@param redisClient goutilsRedis.Client - REDIS client
@returns new workflow client
func NewWorkflowScheduler ¶
func NewWorkflowScheduler( parentCtx context.Context, workflowConfig models.WorkflowSchedulerConfig, taskSchedulerQueue string, dbClient db.Client, redisClient goutilsRedis.Client, onFatalCB models.OnFatalCB, ) (workflow.Scheduler, error)
NewWorkflowScheduler helper function to define new Workflow Engine scheduler.
@param parentCtx context.Context - the parent execution context of the scheduler
@param workflowConfig models.WorkflowSchedulerConfig - workflow scheduler config
@param taskSchedulerQueue string - task engine scheduler request queue name
@param dbClient db.Client - persistence client; see NewPersistenceClient
@param redisClient goutilsRedis.Client - REDIS client
@param onFatalCB models.OnFatalCB - when set, is invoked (at most once) when a queue-processing
goroutine hits an unrecoverable fault instead of terminating the process. reporter identifies
the faulting queue thread; err carries the cause (with code position in its chain); timestamp
is when it was detected. When nil, the default logs and calls log.Fatal, preserving prior
behavior. The goroutine exits after the callback runs.
@returns new workflow scheduler
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package common - common utility structs and functions
|
Package common - common utility structs and functions |
|
Package db - database controllers for system persistence
|
Package db - database controllers for system persistence |
|
mocks
|
|
|
Package models - system data models
|
Package models - system data models |
|
Package notify - subscribable notification framework for the task engine.
|
Package notify - subscribable notification framework for the task engine. |
|
Package task - task processing engine
|
Package task - task processing engine |
|
Package test - various support components used in unit-testing.
|
Package test - various support components used in unit-testing. |
|
utils
|
|
|
atlas-migrate
command
Package main - Atlas GORM migration support binary
|
Package main - Atlas GORM migration support binary |
|
Package workflow - DAG workflow engine layered on the task engine
|
Package workflow - DAG workflow engine layered on the task engine |