Skip to content

Instantly share code, notes, and snippets.

@nathany nathany/
Created Apr 28, 2015

What would you like to do?
Go / Ruby bridge with Sidekiq
brew install redis
gem install sidekiq
go get -u

redis-server /usr/local/etc/redis.conf
sidekiq -r ./sks.rb
go run sk.go
ruby skc.rb
package main
import (
func myJob(message *workers.Msg) {
log.Println("running task", message)
func main() {
// location of redis instance
"server": "localhost:6379",
// instance of the database
"database": "0",
// number of connections to keep open with redis
"pool": "30",
// unique process id for this instance of workers (for proper recovery of in progress jobs on crash)
"process": "1",
// namespace
"namespace": "goworkers",
// poll_interval: "15"
// password: ""
// pull messages from "goqueue" with concurrency of 10
workers.Process("goqueue", myJob, 10)
// send a message
workers.Enqueue("rubyqueue", "MyRubyWorker", []string{"ping"})
// Blocks until process is told to exit via unix signal
require 'sidekiq'
Sidekiq::configure_client do |config|
config.redis = { namespace: "goworkers", size: 1 }
Sidekiq::Client.push "queue" => "goqueue", "class" => "MyGoWorker", "args" => ["pong"]
# sidekiq -r ./sks.rb
require 'sidekiq'
Sidekiq::configure_server do |config|
config.redis = { namespace: "goworkers" }
Sidekiq.options[:queues] = ["rubyqueue"]
class MyRubyWorker
include Sidekiq::Worker
def perform(str)
puts "Hello from Sidekiq: #{str}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.