Skip to content

Instantly share code, notes, and snippets.

@joshjordan
Last active Apr 26, 2018
Embed
What would you like to do?
package main
import (
"fmt"
"time"
"github.com/jrallison/go-workers"
)
func main() {
workers.Configure(map[string]string{
"server": "localhost:6379",
"database": "0",
"pool": "30",
"process": "1",
})
fmt.Println("Enqueuing a job...")
workers.Enqueue("default", "PrototypeConsumerJob", []string{"Bill", time.Now().String()})
time.Sleep(1000 * time.Millisecond)
fmt.Println("Enqueuing a job...")
workers.Enqueue("default", "PrototypeConsumerJob", []string{"Bob", time.Now().String()})
time.Sleep(1000 * time.Millisecond)
fmt.Println("Enqueuing a job...")
workers.Enqueue("default", "PrototypeConsumerJob", []string{"Norbert", time.Now().String()})
time.Sleep(1000 * time.Millisecond)
fmt.Println("Enqueuing a job...")
workers.Enqueue("default", "PrototypeConsumerJob", []string{"Sherbert", time.Now().String()})
time.Sleep(1000 * time.Millisecond)
fmt.Println("Enqueuing a job...")
workers.Enqueue("default", "PrototypeConsumerJob", []string{"Batman", time.Now().String()})
fmt.Println("Waiting for ruby to process jobs...")
time.Sleep(10 * time.Minute)
}
golang: go run go-producer.go
redis: redis-server
ruby: sidekiq -r './ruby-consumer.rb'
require 'sidekiq'
class PrototypeConsumerJob
include Sidekiq::Worker
def perform(name, other_arg)
puts "Received with string '#{name}' and golang timestamp: #{other_arg}"
end
end
@joshjordan
Copy link
Author

joshjordan commented Apr 26, 2018

Output:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment