百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
scherry

scherry

> 编程语言
免费

分拆它。运送它。跟踪它 - 因为每个大工程都值得在上面加点甜酒:甜酒:

102 stars0 点赞3 次浏览
GitHub

工具介绍

分拆它。运送它。跟踪它 - 因为每个大工程都值得在上面加点甜酒:甜酒:


Table of contents

  • How it builds on Asynq
  • Feature comparison
  • Architecture
  • Features
  • Install
  • Prerequisites
  • Configuration
  • Quick start
    • Scheduled job (cron-triggered)
    • Manual job (on-demand trigger)
  • Sharing a consumer across jobs
  • Kafka tuning
    • ConsumerConfig
    • WriterConfig
    • TLS and SASL
  • History console
    • Overview tab
    • History tab
    • Jobs tab
    • Upcoming tab
  • Core interfaces
    • JobExecutor
    • TaskData
    • TaskExecutor
  • Logger
  • Hooks
  • Payroll example
  • Migrating an existing app
  • Job lifecycle
  • Task lifecycle
  • API summary
  • Contributing
  • Third-Party Licenses
  • License
  • Credits

How it builds on Asynq

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:

  • Two-level job → task model — A JobExecutor splits work into N tasks; a TaskExecutor handles one task. The library orchestrates splitting, persistence, fan-out, retries, and job finalization automatically.
  • Kafka fan-out for tasks — Tasks are published to Kafka topics and consumed by scalable consumer groups, decoupling task throughput from the Redis-based job trigger layer.
  • Durable Postgres persistence — Every job and task is written to partitioned scherry_jobs / scherry_tasks tables, giving you a reliable audit trail that survives Redis restarts.
  • FSM-based lifecycle — Jobs and tasks move through an explicit finite-state machine (PENDING → RUNNING → COMPLETED / FAILED / etc.), with well-defined terminal states and automatic job finalization when all tasks settle.
  • Retry topic + DLQ — Failed tasks are re-published to a dedicated retry topic (with configurable delay) rather than being held in Redis. Tasks that exhaust all retries are published to a DLQ topic for inspection.
  • Manual / on-demand jobs — RegisterManual + Trigger lets you fire a job from an HTTP handler or event without a cron schedule.
  • Task distribution keys — An optional Kafka partition key (DistributionKey) routes related tasks to the same partition/consumer, preserving ordering and enabling consumer affinity.
  • Duplicate-run suppression — 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).
  • Execution hooks — OnTasksPublished, OnTaskStarted, OnTaskFinished, OnJobFinished callbacks for Prometheus metrics or any custom instrumentation.
  • History console — A built-in web UI served on its own port, backed by Postgres, showing job/task progress, timings, retry lineage, and a one-click retry action.

Feature comparison

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.

Architecture

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:

  1. Retries remaining — the task status is reset to 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.
  2. No retries left — the task transitions to 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.

Features

Scheduling and triggering

  • Cron-scheduled jobs — Register with a cron expression; Asynq fires the job automatically at the configured schedule
  • Manual / on-demand jobs — RegisterManual + Trigger to fire a job from an HTTP handler, event stream, or any programmatic call
  • CancelPrevious — when enabled, starting a new run of a job automatically cancels any previous in-flight run of the same job
  • Enabled callback — a per-job func() bool evaluated at execution time; returning false rejects the run without removing the registration

Execution and fan-out

  • Job → task splitting — JobExecutor.Execute returns a []TaskData; each item becomes one persisted task and one Kafka message
  • Parallel task execution — tasks are consumed by a dedicated Kafka consumer group per job; task throughput scales independently of the Redis/Asynq layer
  • Duplicate-run suppression — ExecuteJob 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)
  • Task distribution keys — optional 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)
  • Shared consumers — 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

  • Retry topic with delay — on failure, tasks with retries remaining are re-published to a dedicated Kafka retry topic after the configured RetryDelay, then consumed and re-executed automatically
  • Dead-letter queue (DLQ) — tasks that exhaust all retry attempts transition to MAX_RETRIES_EXHAUSTED and are published to a DLQ Kafka topic for offline inspection or manual replay
  • Programmatic job retry — RetryJob clones a terminal job and re-queues its failed/exhausted tasks; fullRetry: true re-runs every task in the original job

Observability

  • Durable Postgres history — every job and task is persisted to partitioned scherry_jobs / scherry_tasks tables, including execution timing (started_at, finished_at, duration_ms)
  • FSM-based lifecycle — jobs and tasks move through an explicit finite-state machine with well-defined transitions; the library auto-finalizes a job once all its tasks reach a terminal state
  • Execution hooks — OnTasksPublished, OnTaskStarted, OnTaskFinished, OnJobFinished callbacks for Prometheus metrics or any custom instrumentation
  • History console — built-in web UI served on its own port, backed by Postgres; shows per-job progress, timings, retry lineage, and a one-click retry action

Extensibility

  • **Pluggab

Issues· 2 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

distributed-systemsgolangjob-queue

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年9月9日
最后更新2026年9月18日
分类编程语言
定价免费

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言