Skip to content

Instantly share code, notes, and snippets.

@joshjordan
Last active April 26, 2018 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshjordan/6415337e8a75fa068bb2923fdb3195e9 to your computer and use it in GitHub Desktop.
Save joshjordan/6415337e8a75fa068bb2923fdb3195e9 to your computer and use it in GitHub Desktop.
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