Skip to content
Mike Perham edited this page Jun 10, 2016 · 29 revisions

Want to run some background jobs in Sidekiq.cr? Let's get you started!

Create an App

Create a new Crystal application if necessary.

crystal init app sample

Integrate into your App

Pull in Sidekiq.cr as a dependency into your application in shards.yml:

dependencies:
  sidekiq:
    github: mperham/sidekiq.cr
    branch: master

Run shards update to download the Sidekiq source.

Create your First Worker

In src/sample/workers.cr:

require "sidekiq"

module Sample
  class MyWorker
    include Sidekiq::Worker

    def perform(x : Int64)
      logger.info "hello!"
    end
  end
end

Build the Sidekiq binary

With Crystal, you build and run a single binary with Sidekiq and all your worker code compiled into it. There is a sample script in examples/sidekiq.cr which shows how to configure, register your workers and boot Sidekiq.

Clone this wiki locally