Running Tasks
Once you have a running worker, you’ll want to run your tasks. Hatchet provides a number of ways of triggering task runs, from which you should select the one(s) that best suit(s) your use case.
- Tasks can be run, and have their results waited on
- Tasks can be enqueued without waiting for their results (“fire and forget”).
- Tasks can be run on cron schedules.
- Tasks can be triggered by events.
- Tasks can be scheduled for a later time.
Each of these methods for triggering tasks have their own uses in different scenarios, and the next few sections will give some examples of each.
These methods can be invoked directly from the workflow definition, or from other services.
Invoking Tasks from your Application
Often it is useful to trigger tasks from your application (i.e. an API service). Hatchet consistently serializes inputs so the invocation of a task is the same regardless of the language or framework you are using.
Creating a “Stub” Task on your External Service (Recommended)
The recommended way to trigger a task from an external service is to create a “stub” task on your external service. This is a hatchet task or workflow that has the same name and input/output types as the task you want to trigger on your hatchet worker, but without the function or other configuration.
This allows you to have polyglot, fully typed interface with full sdk support.