How To Use Sidekiq As Background Job Processor For Golang

How To Use Sidekiq As Background Job Processor For Golang

Using one of the most popular frameworks, Sidekiq with Golang

Context

Many developers start with Rails and as the application grows they start writing code in other languages like Golang. Generally, Sidekiq is used for background jobs Rails. Why not use Sidekiq for Golang!

Open Source Library

Sidekiq compatible background workers in golang.

jrallison/go-workers

Run the following command.

go get github.com/jrallison/go-workers

Sample Code

AddJob method provides a mechanism to queue a new job in the Sidekiq queue.

The method can be used to add a job in the queue as follows:

Here is the sample worker:

The above code creates a worker. We still have to run it. For running various workers we created an executor. It looks like this:

Build the executor and run it. This runs the worker.

Comments are closed.