Skip to main content
Jobs define the configuration for a specific task that can be executed. They act as templates for Runs.

Job Model

The Job struct (defined in apps/strait/internal/domain/types.go) contains the following fields:

Slugs and Project Scoping

Jobs are scoped to a project_id. The slug must be unique within that project. This allows for clean URLs and API access patterns like /v1/jobs/{jobID}.

Scheduling and Execution

  • Cron: Standard 5-field syntax supported via robfig/cron/v3.
  • Execution Windows: Restricts job execution to specific times (e.g., business hours).

Concurrency and Rate Limiting

  • Max Concurrency: Limits the number of parallel executions for a single job definition.
  • Rate Limiting: Prevents thundering herds by capping the number of runs over a sliding window.
  • Deduplication: Uses dedup_window_secs and an idempotency key to ignore duplicate trigger requests within a short timeframe.

Per-Key Concurrency

When max_concurrency_per_key is set on a job, each run must provide a concurrency_key. Runs sharing the same key are limited to max_concurrency_per_key concurrent active executions. This is useful for per-tenant or per-resource throttling. For example, setting max_concurrency_per_key: 1 ensures only one run per key executes at a time, creating a per-key serial queue.

Named Rate Limit Keys

The rate_limit_keys field allows defining multiple named rate limits on a single job. Each entry specifies:
  • name: identifier for the rate limit
  • max: maximum runs in the window
  • window_secs: window duration in seconds
This extends the flat rate_limit_max/rate_limit_window_secs to support more granular control.

Job Versioning

Every time a job’s configuration is updated, the version field is automatically incremented. This ensures that:
  1. In-flight runs continue using the configuration they were triggered with.
  2. Historical data remains accurate to the job’s state at the time of execution.

Webhook Configuration

Jobs can be configured with a webhook_url and webhook_secret. When a run completes, fails, or times out, a signed POST request is sent to this URL.
Always use the webhook_secret to verify webhook authenticity via X-Strait-Signature + X-Strait-Timestamp (and optionally compatibility X-Webhook-Signature).

Environment Binding

Jobs can be linked to an environment_id. This allows Strait to apply environment-specific overrides, such as changing the endpoint_url when running in a “Staging” vs “Production” environment.
  • Runs: The execution instances of a job.
  • Workflows: DAGs that coordinate multiple jobs.
  • Job Groups: Logical containers for related jobs within a project.