snawar92 / sidekiq-staged_push

sidekiq-staged_push is an extension to Sidekiq that implements a strategy of pushing jobs to Redis that involves an intermediary database table. This allows you to leverage the power of Sidekiq while still treating your jobs as if they were stored in the database for the purpose of transactions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sidekiq-staged_push

sidekiq-staged_push is an extension to Sidekiq that implements a strategy of pushing jobs to Redis that involves an intermediary database table. It is developed based on the approach described in Transactionally Staged Job Drains in Postgres. Quoting the author:

With this pattern, jobs aren’t immediately sent to the job queue. Instead, they’re staged in a table within the relational database itself, and the ACID properties of the running transaction keep them invisible until they’re ready to be worked. A secondary enqueuer process reads the table and sends any jobs it finds to the job queue before removing their rows.

This allows you to leverage the power of Sidekiq while still treating your jobs as if they were stored in the database for the purpose of transactions. See the demo app.

Installation

Add this line to your application's Gemfile:

gem 'sidekiq-staged_push'

And then execute:

$ bundle

In config/initializers/sidekiq.rb:

Sidekiq::StagedPush.enable!

And finally, create the tables:

$ rails generate sidekiq:staged_push:install
$ rails db:migrate

Gotchas

  1. The gem currently assumes that you're running only one Sidekiq process or using Sidekiq Enterprise. Jobs may be processed multiple times if this is not true.
  2. SomeWorker.perform_bulk([[1], [2], [3]]) is inconsistent with other methods, because it schedules to Redis immediately.

Development

You need Docker with Docker Compose.

make build
make bundle

Then you can run:

make test
make rubocop

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/adamniedzielski/sidekiq-staged_push. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the sidekiq-staged_push project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

About

sidekiq-staged_push is an extension to Sidekiq that implements a strategy of pushing jobs to Redis that involves an intermediary database table. This allows you to leverage the power of Sidekiq while still treating your jobs as if they were stored in the database for the purpose of transactions.

License:MIT License


Languages

Language:Ruby 94.0%Language:Makefile 2.6%Language:Dockerfile 2.1%Language:Shell 1.3%