0.03
No commit activity in last 3 years
No release in over 3 years
Easily run multiple methods per sidekiq worker
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 4.2
 Project Readme

Sidekiq Runner

Code Climate

This gem provides easily run multiple methods per sidekiq worker

Installing

gem 'sidekiq_runner'

Example

# Your worker
class UrlShortenerWorker
  include Sidekiq::Worker
  sidekiq_options backtrace: true, queue: 'url_shortener', retry: 2

  def create_from_google(params)
    # id = params[:id]
    # Video.find(id)
    # Do something here
  end
  
  def create_from_bitly(params)
    # id = params[:id]
    # Video.find(id)
    # Do something here
  end
  
  def my_other_method
    # Do something here
  end
end

Run create_from_google method

SidekiqRunner::Runner.enqueue('UrlShortenerWorker', 'create_from_google', { id: 1, my_other_arg: 2 })
# or
SidekiqRunner::Runner.run('UrlShortenerWorker', 'create_from_google', { id: 1, my_other_arg: 2 })

Run create_from_bitly method

SidekiqRunner::Runner.enqueue('UrlShortenerWorker', 'create_from_bitly', { id: 1, my_other_arg: 2 })
# or
SidekiqRunner::Runner.run('UrlShortenerWorker', 'create_from_bitly', { id: 1, my_other_arg: 2 })

Run my_other_method method

SidekiqRunner::Runner.enqueue('UrlShortenerWorker', 'my_other_method')
# or
SidekiqRunner::Runner.run('UrlShortenerWorker', 'my_other_method')

NOTE

enqueue method gets queue from sidekiq_options

Difference enqueue & run

run method runs job instantly in without production environments, sends job to queue only in production. enqueue method sends job to queue in all environments

Running Tests

$ bundle install
$ bundle exec rake test

If you need to test against local gems, use Bundler's gem :path option in the Gemfile and also edit test/support/test_helper.rb and tell the tests where the gem is checked out.