Documentation ¶
Overview ¶
Workers can be created via
w, err := worker.NewWorker( // ... options )
You can then run the workers in blocking fashion using:
w.Run()
Or in non-blocking fashion using:
w.Start()
Registering Integrations ¶
You can register all integrations using the WithIntegrations option, which takes a list of integrations as an argument:
worker.NewWorker( worker.WithIntegrations( myIntegration, ), )
Adding Workflow Files ¶
By default, the worker will load workflow files from the .hatchet directory. You can override this using the WithWorkflowFiles option:
worker.NewWorker( worker.WithWorkflowFiles( myWorkflowFile, ), )
Connecting to Temporal ¶
By default, the worker will connect to a Temporal instance using the following environment variables, which can be overriden:
TEMPORAL_CLIENT_HOST_PORT=127.0.0.1:7233 TEMPORAL_CLIENT_NAMESPACE=default
The default client supports the following options:
TEMPORAL_CLIENT_HOST_PORT TEMPORAL_CLIENT_NAMESPACE TEMPORAL_CLIENT_TLS_ROOT_CA TEMPORAL_CLIENT_TLS_ROOT_CA_FILE TEMPORAL_CLIENT_TLS_CERT TEMPORAL_CLIENT_TLS_CERT_FILE TEMPORAL_CLIENT_TLS_KEY TEMPORAL_CLIENT_TLS_KEY_FILE TEMPORAL_CLIENT_TLS_SERVER_NAME
You can also override the Temporal client using the WithTemporalClient option:
worker.NewWorker( worker.WithTemporalClient( myTemporalClient, ), )
Index ¶
- func StartWorkers(ctx context.Context, workers ...Worker) error
- func WithIntegrations(ints ...integrations.Integration) workerOptFunc
- func WithQueueName(queueName string) workerOptFunc
- func WithTemporalClient(tc client.Client) workerOptFunc
- func WithWorkflowFiles(files []*types.WorkflowFile) workerOptFunc
- type Worker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartWorkers ¶
StartWorkers starts a set of workers. It will block until the context is cancelled.
func WithIntegrations ¶
func WithIntegrations(ints ...integrations.Integration) workerOptFunc
WithIntegrations registers all integrations with the worker. See integrations.Integration to see the interface integrations must satisfy.
func WithQueueName ¶
func WithQueueName(queueName string) workerOptFunc
WithQueueName sets the queue name to use for the worker. Note that this will override the queue name set in the default Temporal client, but will not override the queue name set in the Temporal client passed in with WithTemporalClient.
func WithTemporalClient ¶
WithTemporalClient sets the temporal client to use for the worker. Note that the default queue registered with the Temporal client will be used if jobs and steps do not specify a queue.
func WithWorkflowFiles ¶
func WithWorkflowFiles(files []*types.WorkflowFile) workerOptFunc
WithWorkflowFiles sets the workflow files to use for the worker. If this is not passed in, the workflows files will be loaded from the .hatchet folder in the current directory.