back to home

riverqueue / river

Fast and reliable background jobs in Go

4,884 stars
141 forks
45 issues
GoPLpgSQLMakefile

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing riverqueue/river in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/riverqueue/river)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

River River is a robust high-performance job processing system for Go and Postgres. See [homepage], [docs], and [godoc], as well as the [River UI][riverui] and [its live demo][riveruidemo]. Being built for Postgres, River encourages the use of the same database for application data and job queue. By enqueueing jobs transactionally along with other database changes, whole classes of distributed systems problems are avoided. Jobs are guaranteed to be enqueued if their transaction commits, are removed if their transaction rolls back, and aren't visible for work _until_ commit. See [transactional enqueueing] for more background on this philosophy. Job args and workers Jobs are defined in struct pairs, with an implementation of [ ] and one of [ ]. Job args contain annotations and define how jobs are serialized to and from the database, along with a "kind", a stable string that uniquely identifies the job. Workers expose a function that dictates how jobs run. Registering workers Jobs are uniquely identified by their "kind" string. Workers are registered on start up so that River knows how to assign jobs to workers: Starting a client A River [ ] provides an interface for job insertion and manages job processing and [maintenance services]. A client's created with a database pool, [driver], and config struct containing a bundle and other settings. Here's a working one queue ( ) with up to 100 worker goroutines at a time: Insert-only clients It's often desirable to have a client that'll be used for inserting jobs, but not working them. This is possible by omitting the configuration, and skipping the call to : can also be omitted, but it's better to include it so River can check that inserted job kinds have a worker that can run them. Stopping The client should also be stopped on program shutdown: There are some complexities around ensuring clients stop cleanly, but also in a timely manner. See [graceful shutdown] for more details on River's stop modes. Inserting jobs [ ] is used in conjunction with an instance of job args to insert a job to work on a transaction: See the [ example] for complete code. Other features • [Batch job insertion] for efficiently inserting many jobs at once using Postgres . • [Cancelling jobs] from inside a work function. • [Error and panic handling]. • [Multiple queues] to better guarantee job throughput, worker availability, and isolation between components. • [Periodic and cron jobs]. • [Scheduled jobs] that run automatically at their scheduled time in the future. • [Snoozing jobs] from inside a work function. • [Subscriptions] to queue activity and statistics, providing easy hooks for telemetry like logging and metrics. • [Test helpers] to verify that jobs are inserted as expected. • [Transactional job completion] to guarantee job completion commits with other changes in a transaction. • [Unique jobs] by args, period, queue, and state. • [Web UI] for inspecting and interacting with jobs and queues. • [Work functions] for simplified worker implementation. Cross language enqueueing River supports inserting jobs in some non-Go languages which are then worked by Go implementations. This may be desirable in performance sensitive cases so that jobs can take advantage of Go's fast runtime. • Inserting jobs from Python. • Inserting jobs from Ruby. Development See [developing River]. Thank you River was in large part inspired by our experiences with other background job libraries over the years, most notably: • Oban in Elixir. • Que, Sidekiq, Delayed::Job, and GoodJob in Ruby. • Hangfire in .NET. Thank you for driving the software ecosystem forward. [ ]: https://pkg.go.dev/github.com/riverqueue/river#Client [ ]: https://pkg.go.dev/github.com/riverqueue/river#Client.InsertTx [ example]: https://pkg.go.dev/github.com/riverqueue/river#example-package-InsertAndWork [ ]: https://pkg.go.dev/github.com/riverqueue/river#JobArgs [ ]: https://pkg.go.dev/github.com/riverqueue/river#Worker [Batch job insertion]: https://riverqueue.com/docs/batch-job-insertion [Cancelling jobs]: https://riverqueue.com/docs/cancelling-jobs [Error and panic handling]: https://riverqueue.com/docs/error-handling [Multiple queues]: https://riverqueue.com/docs/multiple-queues [Periodic and cron jobs]: https://riverqueue.com/docs/periodic-jobs [Scheduled jobs]: https://riverqueue.com/docs/scheduled-jobs [Snoozing jobs]: https://riverqueue.com/docs/snoozing-jobs [Subscriptions]: https://riverqueue.com/docs/subscriptions [Test helpers]: https://riverqueue.com/docs/testing [Transactional job completion]: https://riverqueue.com/docs/transactional-job-completion [Unique jobs]: https://riverqueue.com/docs/unique-jobs [Web UI]: https://github.com/riverqueue/riverui [Work functions]: https://riverqueue.com/docs/work-functions [developing River]: https://github.com/riverqueue/river/blob/master/docs/development.md [docs]: https://riverqueue.com/docs [driver]: https://riverqueue.com/docs/database-drivers [godoc]: https://pkg.go.dev/github.com/riverqueue/river [graceful shutdown]: https://riverqueue.com/docs/graceful-shutdown [homepage]: https://riverqueue.com [maintenance services]: https://riverqueue.com/docs/maintenance-services [riverui]: https://github.com/riverqueue/riverui [riveruidemo]: https://ui.riverqueue.com [transactional enqueueing]: https://riverqueue.com/docs/transactional-enqueueing