How opsway-io/boomerang works
Project type and purpose
• From the README and file names, Boomerang is an open-source Go library for distributed, recurring task scheduling built on top of Redis. It is not a full-stack web app or microservices suite, but rather a client library that you embed in your Go processes to share a common Redis-backed scheduler.
File structure
• Top-level Go modules (go.mod, go.sum) indicate a standalone library.
• schedule.go / task.go contain the core scheduler and task data-structures.
• schedule_test.go holds unit tests.
• docker-compose.yaml spins up a Redis instance for local testing.
• .github/workflows/test.yaml defines CI to run tests on every PR.
README for additional insights
• Shows how client code calls sch.Add(…) to schedule a recurring task, and sch.On(…) to register a callback.
• Implies the scheduler polls Redis for due tasks, executes the callback, then reschedules the next run.
Main components
a. Application process (your Go service)
b. Boomerang client library inside that process
c. Redis instance (single node or cluster)
d. Task execution callback (user code)
e. (Optional) Docker-Compose environment for local dev
Relationships and data flows
• At startup, your Go process loads the Boomerang library.
• When you call sch.Add(ctx, task, interval, startTime), the library performs a Redis ZADD (or similar) to insert the task into a sorted set keyed by next execution timestamp.
• The scheduler goroutine inside the library continuously polls Redis (e.g., via ZRANGEBYSCORE) for tasks whose score ≤ now.
• On each tick, due tasks are popped (e.g., via a Lua script or transactional ZPOPMIN/COPY pattern), the callback registered by sch.On(...) is invoked, and then the task is rescheduled by another ZADD with an updated timestamp.
• All instances of your service share the same Redis backend, so they coordinate to avoid double-execution.
Architectural patterns and design principles
• Brokerless distributed scheduling via Redis sorted sets
• Poll-and-pop pattern for work coordination
• Idempotent task registration and rescheduling
• Horizontal scalability: multiple Go processes can run side-by-side
Relevant technologies
• Go modules (go.mod)
• Redis (sorted sets & optional Lua scripting)
• Docker-Compose for local Redis environment
• GitHub Actions for CI
Essential elements without over-splitting
• Runtime interaction between your app, the library, and Redis.