[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-71475":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":23,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":32,"readmeContent":33,"aiSummary":34,"trendingCount":16,"starSnapshotCount":16,"syncStatus":35,"lastSyncTime":36,"discoverSource":37},71475,"river","riverqueue\u002Friver","riverqueue","Fast and reliable background jobs in Go","https:\u002F\u002Friverqueue.com",null,"Go",5200,159,19,38,0,11,32,99,33,108.51,"Mozilla Public License 2.0",false,"master",[26,27,28,29,30,31],"background-jobs","go","golang","postgres","postgresql","queue","2026-06-12 04:01:01","# River [![Build Status](https:\u002F\u002Fgithub.com\u002Friverqueue\u002Friver\u002Factions\u002Fworkflows\u002Fci.yaml\u002Fbadge.svg?branch=master)](https:\u002F\u002Fgithub.com\u002Friverqueue\u002Friver\u002Factions) [![Go Reference](https:\u002F\u002Fpkg.go.dev\u002Fbadge\u002Fgithub.com\u002Friverqueue\u002Friver.svg)](https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Friverqueue\u002Friver)\n\nRiver is a robust high-performance job processing system for Go and Postgres.\n\nSee [homepage], [docs], and [godoc], as well as the [River UI][riverui] and [its\nlive demo][riveruidemo].\n\nBeing built for Postgres, River encourages the use of the same database for\napplication data and job queue. By enqueueing jobs transactionally along with\nother database changes, whole classes of distributed systems problems are\navoided. Jobs are guaranteed to be enqueued if their transaction commits, are\nremoved if their transaction rolls back, and aren't visible for work _until_\ncommit. See [transactional enqueueing] for more background on this philosophy.\n\n## Job args and workers\n\nJobs are defined in struct pairs, with an implementation of [`JobArgs`] and one\nof [`Worker`].\n\nJob args contain `json` annotations and define how jobs are serialized to and\nfrom the database, along with a \"kind\", a stable string that uniquely identifies\nthe job.\n\n```go\ntype SortArgs struct {\n    \u002F\u002F Strings is a slice of strings to sort.\n    Strings []string `json:\"strings\"`\n}\n\nfunc (SortArgs) Kind() string { return \"sort\" }\n```\n\nWorkers expose a `Work` function that dictates how jobs run.\n\n```go\ntype SortWorker struct {\n    \u002F\u002F An embedded WorkerDefaults sets up default methods to fulfill the rest of\n    \u002F\u002F the Worker interface:\n    river.WorkerDefaults[SortArgs]\n}\n\nfunc (w *SortWorker) Work(ctx context.Context, job *river.Job[SortArgs]) error {\n    sort.Strings(job.Args.Strings)\n    fmt.Printf(\"Sorted strings: %+v\\n\", job.Args.Strings)\n    return nil\n}\n```\n\n## Registering workers\n\nJobs are uniquely identified by their \"kind\" string. Workers are registered on\nstart up so that River knows how to assign jobs to workers:\n\n```go\nworkers := river.NewWorkers()\n\u002F\u002F AddWorker panics if the worker is already registered or invalid:\nriver.AddWorker(workers, &SortWorker{})\n```\n\n## Starting a client\n\nA River [`Client`] provides an interface for job insertion and manages job\nprocessing and [maintenance services]. A client's created with a database pool,\n[driver], and config struct containing a `Workers` bundle and other settings.\nHere's a `Client` working one queue (`\"default\"`) with up to 100 worker\ngoroutines at a time:\n\n```go\nriverClient, err := river.NewClient(riverpgxv5.New(dbPool), &river.Config{\n    Queues: map[string]river.QueueConfig{\n        river.QueueDefault: {MaxWorkers: 100},\n    },\n    Workers: workers,\n})\nif err != nil {\n    panic(err)\n}\n\n\u002F\u002F Run the client inline. All executed jobs will inherit from ctx:\nif err := riverClient.Start(ctx); err != nil {\n    panic(err)\n}\n```\n\n`Workers` can also be omitted, but it's better to include it so River can check\nthat inserted job kinds have a worker that can run them.\n\n### Stopping\n\nThe client should also be stopped on program shutdown:\n\n```go\n\u002F\u002F Stop fetching new work and wait for active jobs to finish.\nif err := riverClient.Stop(ctx); err != nil {\n    panic(err)\n}\n```\n\nThere are some complexities around ensuring clients stop cleanly, but also in a\ntimely manner. See [graceful shutdown] for more details on River's stop modes.\n\n[Insert-only clients](\u002Fdocs\u002Finsert-only-clients) will insert jobs, but not work\nthem, and don't need to be started or stopped.\n\n## Inserting jobs\n\n[`Client.InsertTx`] is used in conjunction with an instance of job args to\ninsert a job to work on a transaction:\n\n```go\n_, err = riverClient.InsertTx(ctx, tx, SortArgs{\n    Strings: []string{\n        \"whale\", \"tiger\", \"bear\",\n    },\n}, nil)\n\nif err != nil {\n    panic(err)\n}\n```\n\nSee the [`InsertAndWork` example] for complete code.\n\n## Other features\n\n  - [Batch job insertion] for efficiently inserting many jobs at once using\n    Postgres `COPY FROM`.\n\n  - [Cancelling jobs] from inside a work function.\n\n  - [Error and panic handling].\n\n  - [Multiple queues] to better guarantee job throughput, worker availability,\n    and isolation between components.\n\n  - [Periodic and cron jobs].\n\n  - [Scheduled jobs] that run automatically at their scheduled time in the\n    future.\n\n  - [Snoozing jobs] from inside a work function.\n\n  - [Subscriptions] to queue activity and statistics, providing easy hooks for\n    telemetry like logging and metrics.\n\n  - [Test helpers] to verify that jobs are inserted as expected.\n\n  - [Transactional job completion] to guarantee job completion commits with\n    other changes in a transaction.\n\n  - [Unique jobs] by args, period, queue, and state.\n\n  - [Web UI] for inspecting and interacting with jobs and queues.\n\n  - [Work functions] for simplified worker implementation.\n\n## Cross language enqueueing\n\nRiver 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.\n\n  - [Inserting jobs from Python](https:\u002F\u002Friverqueue.com\u002Fdocs\u002Fpython).\n  - [Inserting jobs from Ruby](https:\u002F\u002Friverqueue.com\u002Fdocs\u002Fruby).\n\n## Development\n\nSee [developing River].\n\n## Thank you\n\nRiver was in large part inspired by our experiences with other background job libraries over the years, most notably:\n\n- [Oban](https:\u002F\u002Fgithub.com\u002Fsorentwo\u002Foban) in Elixir.\n- [Que](https:\u002F\u002Fgithub.com\u002Fque-rb\u002Fque), [Sidekiq](https:\u002F\u002Fgithub.com\u002Fsidekiq\u002Fsidekiq), [Delayed::Job](https:\u002F\u002Fgithub.com\u002Fcollectiveidea\u002Fdelayed_job), and [GoodJob](https:\u002F\u002Fgithub.com\u002Fbensheldon\u002Fgood_job) in Ruby.\n- [Hangfire](https:\u002F\u002Fwww.hangfire.io\u002F) in .NET.\n\nThank you for driving the software ecosystem forward.\n\n[`Client`]: https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Friverqueue\u002Friver#Client\n[`Client.InsertTx`]: https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Friverqueue\u002Friver#Client.InsertTx\n[`InsertAndWork` example]: https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Friverqueue\u002Friver#example-package-InsertAndWork\n[`JobArgs`]: https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Friverqueue\u002Friver#JobArgs\n[`Worker`]: https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Friverqueue\u002Friver#Worker\n[Batch job insertion]: https:\u002F\u002Friverqueue.com\u002Fdocs\u002Fbatch-job-insertion\n[Cancelling jobs]: https:\u002F\u002Friverqueue.com\u002Fdocs\u002Fcancelling-jobs\n[Error and panic handling]: https:\u002F\u002Friverqueue.com\u002Fdocs\u002Ferror-handling\n[Multiple queues]: https:\u002F\u002Friverqueue.com\u002Fdocs\u002Fmultiple-queues\n[Periodic and cron jobs]: https:\u002F\u002Friverqueue.com\u002Fdocs\u002Fperiodic-jobs\n[Scheduled jobs]: https:\u002F\u002Friverqueue.com\u002Fdocs\u002Fscheduled-jobs\n[Snoozing jobs]: https:\u002F\u002Friverqueue.com\u002Fdocs\u002Fsnoozing-jobs\n[Subscriptions]: https:\u002F\u002Friverqueue.com\u002Fdocs\u002Fsubscriptions\n[Test helpers]: https:\u002F\u002Friverqueue.com\u002Fdocs\u002Ftesting\n[Transactional job completion]: https:\u002F\u002Friverqueue.com\u002Fdocs\u002Ftransactional-job-completion\n[Unique jobs]: https:\u002F\u002Friverqueue.com\u002Fdocs\u002Funique-jobs\n[Web UI]: https:\u002F\u002Fgithub.com\u002Friverqueue\u002Friverui\n[Work functions]: https:\u002F\u002Friverqueue.com\u002Fdocs\u002Fwork-functions\n[developing River]: https:\u002F\u002Fgithub.com\u002Friverqueue\u002Friver\u002Fblob\u002Fmaster\u002Fdocs\u002Fdevelopment.md\n[docs]: https:\u002F\u002Friverqueue.com\u002Fdocs\n[driver]: https:\u002F\u002Friverqueue.com\u002Fdocs\u002Fdatabase-drivers\n[godoc]: https:\u002F\u002Fpkg.go.dev\u002Fgithub.com\u002Friverqueue\u002Friver\n[graceful shutdown]: https:\u002F\u002Friverqueue.com\u002Fdocs\u002Fgraceful-shutdown\n[homepage]: https:\u002F\u002Friverqueue.com\n[maintenance services]: https:\u002F\u002Friverqueue.com\u002Fdocs\u002Fmaintenance-services\n[riverui]: https:\u002F\u002Fgithub.com\u002Friverqueue\u002Friverui\n[riveruidemo]: https:\u002F\u002Fui.riverqueue.com\n[transactional enqueueing]: https:\u002F\u002Friverqueue.com\u002Fdocs\u002Ftransactional-enqueueing\n","River 是一个用于 Go 和 Postgres 的高性能后台任务处理系统。它通过将任务队列与应用程序数据存储在同一数据库中，实现了事务性入队，从而避免了分布式系统中的许多常见问题。核心功能包括事务性任务入队、结构化的任务定义和工作器注册机制。River 适用于需要可靠且高效处理后台任务的 Go 应用程序，特别是在使用 Postgres 数据库的场景下。通过 River，开发者可以确保任务在事务提交后才可见，并且在事务回滚时自动移除，从而保证了数据的一致性和可靠性。",2,"2026-06-11 03:37:55","high_star"]