Skip to content

A Sidekiq Web extension to enqueue/schedule jobs with custom perform params in Web UI. Support both Sidekiq::Worker and ActiveJob.

Notifications You must be signed in to change notification settings

richfisher/sidekiq-enqueuer

Repository files navigation

Sidekiq::Enqueuer

Build Status

A Sidekiq Web extension to enqueue/schedule job in Web UI. Support both Sidekiq::Worker and ActiveJob.

Installation

Add this line to your application's Gemfile:

gem 'sidekiq-enqueuer'

And then execute:

$ bundle

Edit config/initializers/sidekiq.rb, add following line

require 'sidekiq/enqueuer'

Optionally, provide a list of Jobs to display on the new tab, on a new initializer file. Worry not, when no configuration is provided, All jobs will be displayed

# config/initializers/sidekiq_enqueuer_config.rb
require 'sidekiq/enqueuer'

Sidekiq::Enqueuer.configure do |config|
  config.jobs = [MyAwesomeJob1, MyModule::MyAwesomeJob2]
end

Notes:

Queuing & ActiveJob support

Use default sidekiq queue adapter for Jobs including Sidekiq::Worker or Jobs inheriting from ActiveJob::base

ActiveJob::Base.queue_adapter = :sidekiq

https://github.com/mperham/sidekiq/wiki/Active-Job#active-job-setup

Jobs action param mapping.

This gem dynamically infers the params required in the perform or perform_in action in your Job / Worker. It is important those actions (either of them) won't hide the actual params into a single *args one. In that case it will be impossible to infer the params for your method.

Want to verify this last line? Run this in a rails console:

MyJob.instance_method(:perform).parameters            # change :perform for your implemented method
>> [[:req, :param1], [:opt, :param2], [:opt, :param3]]   # Good output

=> [[:rest, :args], [:block, :block]]   # Bad output. Params are being wrapped into a super class.

Enqueuing Jobs:

For Sidekiq, enqueing is being done using Sidekiq::Client.enqueue_to / enqueue_to_in, providing Job, and queue extracted from the Job sidekiq_options hash, defaults to 'default' queue when not present.

For ActiveJob, enqueing is being done calling the very own perform_later instance method. Please advise your Job should respond to perform_later to correctly work.

Usage

  • Open Sidekiq Web, click the Enqueuer tab.

  • You can see a list of job classes/modules and params. Click Enqueue Form.

list

  • Fill the form, click Enqueue or Schedule. form

  • That is it!

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/richfisher/sidekiq-enqueuer.

About

A Sidekiq Web extension to enqueue/schedule jobs with custom perform params in Web UI. Support both Sidekiq::Worker and ActiveJob.

Resources

Stars

Watchers

Forks

Packages

No packages published