All Projects → joelmoss → sidekiq-sequence

joelmoss / sidekiq-sequence

Licence: MIT license
Sequential Sidekiq jobs for Rails

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to sidekiq-sequence

Activejob Scheduler
A background job scheduler for any queue backend
Stars: ✭ 24 (-36.84%)
Mutual labels:  sidekiq, ruby-on-rails
nokul
The Nokul Project
Stars: ✭ 47 (+23.68%)
Mutual labels:  sidekiq, ruby-on-rails
lambdakiq
ActiveJob on SQS & Lambda
Stars: ✭ 131 (+244.74%)
Mutual labels:  sidekiq, background-jobs
Sidekiq Superworker
Directed acyclic graphs of Sidekiq jobs
Stars: ✭ 419 (+1002.63%)
Mutual labels:  sidekiq, background-jobs
Sidekiq Cron
Scheduler / Cron for Sidekiq jobs
Stars: ✭ 1,383 (+3539.47%)
Mutual labels:  sidekiq, ruby-on-rails
Sidekiq
Simple, efficient background processing for Ruby
Stars: ✭ 11,450 (+30031.58%)
Mutual labels:  sidekiq, background-jobs
request store-sidekiq
Provides an easy integration between RequestStore and Sidekiq
Stars: ✭ 32 (-15.79%)
Mutual labels:  sidekiq, ruby-on-rails
has placeholder image
A Ruby gem for generating string based placeholder images in Rails.
Stars: ✭ 20 (-47.37%)
Mutual labels:  ruby-on-rails
human-in-the-loop-machine-learning-tool-tornado
Tornado is a human-in-the-loop machine learning framework that helps you exploit your unlabelled data to train models through a simple and easy to use web interface.
Stars: ✭ 37 (-2.63%)
Mutual labels:  ruby-on-rails
active-date-range
Powerful DateRanges for Ruby and ActiveSupport
Stars: ✭ 38 (+0%)
Mutual labels:  ruby-on-rails
sidekiq alive
Liveness probe for Sidekiq in Kubernetes deployments
Stars: ✭ 142 (+273.68%)
Mutual labels:  sidekiq
rubocop-linter-action
Rubocop Linter Action: A GitHub Action to run Rubocop against your code!
Stars: ✭ 86 (+126.32%)
Mutual labels:  ruby-on-rails
kickstart
Ruby on Rails application templates
Stars: ✭ 61 (+60.53%)
Mutual labels:  ruby-on-rails
chatter
Build a twitter clone in 10 mins with Rails, CableReady, and StimulusReflex
Stars: ✭ 50 (+31.58%)
Mutual labels:  ruby-on-rails
stimulus reflex
Build reactive applications with the Rails tooling you already know and love.
Stars: ✭ 2,001 (+5165.79%)
Mutual labels:  ruby-on-rails
joobq
JoobQ is a fast, efficient asynchronous reliable job queue and job scheduler library processing. Jobs are submitted to a job queue, where they reside until they are able to be scheduled to run in a computing environment.
Stars: ✭ 26 (-31.58%)
Mutual labels:  background-jobs
mobility-actiontext
Translate Rails Action Text rich text with Mobility.
Stars: ✭ 27 (-28.95%)
Mutual labels:  ruby-on-rails
awesome-rails-security
A curated list of security resources for a Ruby on Rails application
Stars: ✭ 36 (-5.26%)
Mutual labels:  ruby-on-rails
darrrr
An SDK for the delegated recovery specfication
Stars: ✭ 43 (+13.16%)
Mutual labels:  ruby-on-rails
new ckeditor
Ruby on Rails + CKEditor 5
Stars: ✭ 27 (-28.95%)
Mutual labels:  ruby-on-rails

Sidekiq::Sequence - Sequential Sidekiq jobs.

Sidekiq is awesome, but it doesn't provide any support for sequential jobs, where a sequence of jobs must be run in a set order.

Sidekiq::Sequence provides a simple yet powerful framework to run a sequence of Sidekiq jobs, where each job runs only when the previous job successfully completes. It relies on Sidekiq's retry functionality to handle failed jobs. So if a job fails, any subsequent jobs will not run. Once the job is retried and is successful, the next job will start.

NOTE: Sidekiq::Sequence is currently only intended for use in Rails applications.

Installation

Add this line to your application's Gemfile:

gem 'sidekiq-sequence'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install sidekiq-sequence

Run the Rails generator to install the database migration:

$ rails g sidekiq_sequence:install
$ rails db:migrate

Usage

Start with a Sequence class which inherits from Sidekiq::Sequence::Base, and define each step of the sequence:

class ContactFormSequence < Sidekiq::Sequence::Base
  step CreateMessage
  step AssignMessage
end

Each step should be a class that includes Sidekiq::Sequence::Worker, and behaves just like a regular Sidekiq Worker:

class ContactFormSequence::CreateMessage
  include Sidekiq::Sequence::Worker

  def perform
    # Perform your job
  end
end

Each Step is run in the order they are defined, and each is a Sidekiq worker. If a worker fails, subsequent steps will not be run, and the worker will be placed in the Sidekiq retry queue. Once it succeeds, the next step will be run, and so on.

Start a Sequence by simply initializing the Sequence class you created:

ContactFormSequence.new name: 'Joel', github: 'joelmoss'

You can pass named arguments, and these will be persisted and available in the Sequence and its workers:

class ContactFormSequence::CreateMessage
  include Sidekiq::Sequence::Worker

  def perform
    @data # -> { name: 'Joel', github: 'joelmoss' }
  end
end

You can also modify Sequence data in any worker, which is great for passing data to subsequent steps:

class ContactFormSequence::AssignMessage
  include Sidekiq::Sequence::Worker

  def perform
    @data[:message] = 'my message' # @data is now { name: 'Joel', github: 'joelmoss', message: 'my message' }
  end
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/joelmoss/sidekiq-sequence. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the 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::Sequence project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].