Guides
Ensuring execution order between jobs using dependencies.
Job dependencies allow you to define a relationship between two jobs, ensuring that one job only runs after another job has reached a specific state.
Concepts
A Job Dependency consists of:
- Job ID: The job that is waiting for the dependency.
- Depends On Job ID: The job that must reach a certain state first.
- Condition: The state the dependency job must reach.
Dependency Conditions
When creating a dependency, you can specify one of the following conditions:
completed(Default): The dependency job must finish successfully.failed: The dependency job must fail.any: The dependency job must reach any terminal state (completed, failed, canceled, etc.).
Use Cases
- Sequential Processing: Ensure Job B (e.g., "Generate Invoice") only runs after Job A (e.g., "Process Payment") completes successfully.
- Error Handling: Trigger Job C (e.g., "Notify Support") only if Job A fails.
- Cleanup: Run Job D (e.g., "Delete Temporary Files") regardless of whether Job A succeeded or failed.
Managing Dependencies
Job dependencies are enabled by default.
Create a Dependency
To make Job B depend on Job A completing successfully:
curl -X POST https://strait.dev/v1/jobs/{jobB_ID}/dependencies \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"depends_on_job_id": "{jobA_ID}",
"condition": "completed"
}'List Dependencies
To see all jobs that a specific job depends on:
curl -H "Authorization: Bearer $API_KEY" \
https://strait.dev/v1/jobs/{jobID}/dependenciesDelete a Dependency
curl -X DELETE https://strait.dev/v1/jobs/{jobID}/dependencies/{dependencyID} \
-H "Authorization: Bearer $API_KEY"Behavior
When a job with dependencies is triggered:
- Strait checks if all dependencies are met.
- If dependencies are not met, the job run may enter a
waitingstate or be delayed until the conditions are satisfied. - Once all dependency conditions are met, the job is moved to the
queuedstate for execution.
Circular dependencies (e.g., Job A depends on Job B, and Job B depends on Job A) are not allowed and will result in a validation error.
Was this page helpful?