
Split it. Ship it. Track it - Because every big job deserves a little scherry on top :cherries:
Split it. Ship it. Track it - Because every big job deserves a little scherry on top :cherries:
Asynq is a Redis-backed distributed task queue: you enqueue individual tasks, workers pick them up, and Asynq handles retries, priorities, and scheduling. It is excellent for simple background job processing.
scherry uses Asynq for one specific responsibility — cron-based job triggering — and then takes over for everything else:
| Responsibility | Technology |
|---|---|
| Scheduled job triggers (cron) | Asynq + Redis |
| Fan-out: splitting a job into parallel tasks | Kafka topics |
| Durable history: job and task state | PostgreSQL |
| Task retries with delay | Kafka retry topic |
| Dead-letter queue for exhausted tasks | Kafka DLQ topic |
| FSM-based lifecycle for jobs and tasks | Built-in state machine |
| History console and audit trail | Embedded web UI (Postgres-backed) |
The key additions over raw Asynq are:
JobExecutor splits work into N tasks; a TaskExecutor handles one task. The library orchestrates splitting, persistence, fan-out, retries, and job finalization automatically.scherry_jobs / scherry_tasks tables, giving you a reliable audit trail that survives Redis restarts.PENDING → RUNNING → COMPLETED / FAILED / etc.), with well-defined terminal states and automatic job finalization when all tasks settle.RegisterManual + Trigger lets you fire a job from an HTTP handler or event without a cron schedule.DistributionKey) routes related tasks to the same partition/consumer, preserving ordering and enabling consumer affinity.ExecuteJob reuses an existing run with the same caller-supplied refID, so a re-fired trigger does not start a second run. Best-effort rather than a guarantee: concurrent triggers sharing a refID can still both create a run (see Idempotency limitations).OnTasksPublished, OnTaskStarted, OnTaskFinished, OnJobFinished callbacks for Prometheus metrics or any custom instrumentation.The table below compares scherry against Asynq (which it wraps) and four other commonly used Go job/task queue libraries.
| Feature | scherry | asynq | River | Machinery | go-quartz |
|---|---|---|---|---|---|
| Task broker / backend | Kafka + Redis | Redis | PostgreSQL | Redis / RabbitMQ / SQS | In-memory |
| Durable job history | PostgreSQL | Redis (volatile) | PostgreSQL | Broker-dependent | ✗ (custom JobQueue required) |
| Two-level job → task model | ✓ | ✗ | ✗ | Partial (chains/groups) | ✗ |
| Kafka fan-out for tasks | ✓ | ✗ | ✗ | ✗ | ✗ |
| FSM-based lifecycle | ✓ | ✗ | ✓ | ✗ | ✗ |
| Cron / scheduled jobs | ✓ | ✓ | ✓ | ✓ | ✓ |
| Manual / on-demand trigger | ✓ | ✓ | ✓ | ✓ | ✓ (RunOnceTrigger) |
| Task retry with delay | ✓ (retry topic) | ✓ | ✓ | ✓ | ✗ |
| Dead-letter queue (DLQ) | ✓ (DLQ topic) | ✓ | ✓ | ✓ | ✗ |
| Task distribution / partition routing | ✓ | ✗ | ✗ | ✗ | ✗ |
| Automatic job finalization | ✓ | ✗ | ✗ | Partial | ✗ |
| Idempotent execution (dedup) | Partial (refID, best-effort) | ✓ (unique option) | ✓ | ✗ | ✗ |
| Execution result persistence | ✓ (Postgres) | ✗ | ✓ | ✓ (backend) | ✗ |
| Execution timing (start/finish/duration) | ✓ | ✗ | ✓ | ✗ | ✗ |
| Built-in history web UI | ✓ | ✓ (asynqmon) | ✓ | ✗ | ✗ |
| Instrumentation hooks | ✓ | ✓ | ✓ | ✓ | ✗ |
| Priority queues | ✗ | ✓ | ✓ | ✗ | ✗ |
| Workflow orchestration (DAG / chains) | ✗ | ✗ | ✓ (Pro) | ✓ | ✗ |
| Open source (free tier) | ✓ | ✓ | ✓ (core) | ✓ | ✓ |
When to choose scherry: if your workload involves large batch jobs (payroll runs, data exports, bulk notifications) that need to be split into thousands of parallel tasks, tracked durably in Postgres, retried reliably via Kafka, and inspected through a history UI — with the cron trigger layer staying lightweight on Redis.
When Asynq alone is enough: for simple background task processing where a single-level queue over Redis is sufficient and you do not need durable Postgres history or Kafka-based fan-out.
When River fits better: if your entire stack already relies on Postgres and you want transactional job enqueueing without a separate broker; River Pro is required for workflow orchestration and guaranteed sequential execution.
When Machinery fits better: if you need broker flexibility (RabbitMQ, AWS SQS) or workflow primitives like chains and chords across a polyglot environment.
When go-quartz fits better: if you need a lightweight, zero-dependency cron/interval scheduler with no external infrastructure; go-quartz is ideal for simple recurring tasks within a single process where durable history, fan-out, retries, and a broker are not required.
Entry points
| Path | How it starts |
|---|---|
| Scheduled job | Asynq cron fires at the configured schedule; calls ExecuteJob via the Asynq ServeMux handler |
| Manual / on-demand job | Your code calls Trigger(ctx, name, refID, metadata); calls ExecuteJob directly |
Retry and DLQ flow
When TaskExecutor.Execute returns an error, the library checks the task's remaining retry count:
PENDING and the message is re-published to the dedicated retry topic after the configured RetryDelay. A separate retry consumer group picks it up and calls ExecuteTask again.MAX_RETRIES_EXHAUSTED and the message is published to the DLQ topic for offline inspection or manual replay. The task is not re-processed automatically.Job completion checks
A job is finalized (COMPLETED, PARTIAL_FAILED, or FAILED) once every one of its tasks has reached a terminal state (COMPLETED, MAX_RETRIES_EXHAUSTED, CANCELLED, REJECTED). Rather than re-evaluating this after every single task completion, JobConfig.JobCompletionCron — a required cron expression — periodically batch-checks that job's RUNNING instances and finalizes any that are ready, the same way Schedule triggers a job's execution on a cron. Register and RegisterManual both reject a JobConfig that leaves JobCompletionCron empty. You can also call Service.CheckJobCompletions(ctx, jobName) directly (e.g. from your own scheduler or an admin action) whenever you want a check to run outside the configured cron. A job created with zero tasks is always finalized immediately, since there would otherwise be nothing to ever trigger it.
Scheduling and triggering
Register with a cron expression; Asynq fires the job automatically at the configured scheduleRegisterManual + Trigger to fire a job from an HTTP handler, event stream, or any programmatic callCancelPrevious — when enabled, starting a new run of a job automatically cancels any previous in-flight run of the same jobEnabled callback — a per-job func() bool evaluated at execution time; returning false rejects the run without removing the registrationExecution and fan-out
JobExecutor.Execute returns a []TaskData; each item becomes one persisted task and one Kafka messageExecuteJob reuses an existing run with the same caller-supplied refID; best-effort, so triggers that overlap in time can still both create a run (see Idempotency limitations)DistributionKey on each TaskData routes related tasks to the same Kafka partition, preserving ordering and enabling consumer affinity (e.g. all tasks for a given customer handled by one worker instance)RegisterShared explicitly couples two or more jobs onto one Kafka consumer, one producer, and one TaskExecutor when you want to pool Kafka resources instead of running an isolated consumer per job (see Sharing a consumer across jobs)Reliability and retries
RetryDelay, then consumed and re-executed automaticallyMAX_RETRIES_EXHAUSTED and are published to a DLQ Kafka topic for offline inspection or manual replayRetryJob clones a terminal job and re-queues its failed/exhausted tasks; fullRetry: true re-runs every task in the original jobObservability
scherry_jobs / scherry_tasks tables, including execution timing (started_at, finished_at, duration_ms)OnTasksPublished, OnTaskStarted, OnTaskFinished, OnJobFinished callbacks for Prometheus metrics or any custom instrumentationExtensibility
No open issues yet, or sync has not completed.