Ruby sidekiq

From wikinotes

Sidekiq lets you run background jobs in ruby.


Documentation

github https://github.com/mperham/sidekiq
official docs https://github.com/mperham/sidekiq/wiki
yard api docs https://www.rubydoc.info/gems/sidekiq/7.1.1
getting started https://github.com/mperham/sidekiq/wiki/Getting-Started
sidekiq config https://github.com/mperham/sidekiq/wiki/Advanced-Options

Locations

general
config/sidekiq.yml config
rails/activejob
config/routes.rb route config (web ui)
config/application.rb application config (activejob)

Configuration

Queues, Concurrency Options

Queues must be configured in advance.
Queues may be assigned a priority score by setting them within a list.

# config/sidekiq.yml

---
:queues:
  - default
  - maintenance
  - [high, 100]  # name: high, priority: 100

Rails

Web-UI

Configure route for sidekiq UI.

require 'sidekiq/web'

Rails.application.routes.draw do
  Sidekiq::Web => '/sidekiq'
end

queue-adapter

Default queue Adapter

# config/application.rb

Rails.application.config.active_job.queue_adapter = :sidekiq

Queue adapter can also be set/overridden per job.

# app/jobs/foo_job.rb

class FooJob < ApplicationJob
  self.queue_adapter = :sidekiq
end