main function that can access powerful context functions for durable operations.
Each main function will be passed the injected context functions as well as the payload that was sent with the trigger.
Types for context functions are stored in the local .compose/ folder and can be referenced from your task files like so:
Task Structure
Every task must export amain function with this signature:
Task Triggers
Tasks are invoked by “triggers”, see Task Triggers for details. Here’s the current types of supported triggers:- Cron - called with no arguments on a time interval expressed as a cron expression.
- HTTP - called by your application or CLI with various auth options
- Onchain - triggered by onchain events, called with a raw logs payload and decodable with Contract classes.
Task-Level Retry Configuration
Configure retries in your app manifest:- Task Failure: If the task throws an error, Our durable execution engine marks it as failed
- Retry Delay: Waits
initial_interval_msbefore first retry - Exponential Backoff: Each retry interval is multiplied by
backoff_factor - Retry Sequence: 2000ms → 3000ms → 4500ms → 6750ms → 10125ms
- Final Failure: After 5 attempts, task is permanently failed
- Default Retry Configuration: By default tasks will be configured to not retry
Task Context
A task’s “main()” function will be injected with task context, see Context for more details. Here’s a brief overview of what context enables.- State Management - Collections
- Blockchain Interactions - evm
- HTTP requests - fetch
- Task to task execution - callTask
- Reading env variables - env