Job Model
TheJob struct (defined in apps/strait/internal/domain/types.go) contains the following fields:
Slugs and Project Scoping
Jobs are scoped to aproject_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_secsand an idempotency key to ignore duplicate trigger requests within a short timeframe.
Per-Key Concurrency
Whenmax_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
Therate_limit_keys field allows defining multiple named rate limits on a single job. Each entry specifies:
name: identifier for the rate limitmax: maximum runs in the windowwindow_secs: window duration in seconds
rate_limit_max/rate_limit_window_secs to support more granular control.
Job Versioning
Every time a job’s configuration is updated, theversion field is automatically incremented. This ensures that:
- In-flight runs continue using the configuration they were triggered with.
- Historical data remains accurate to the job’s state at the time of execution.
Webhook Configuration
Jobs can be configured with awebhook_url and webhook_secret. When a run completes, fails, or times out, a signed POST request is sent to this URL.
Environment Binding
Jobs can be linked to anenvironment_id. This allows Strait to apply environment-specific overrides, such as changing the endpoint_url when running in a “Staging” vs “Production” environment.