Last active
April 26, 2018 12:46
-
-
Save joshjordan/6415337e8a75fa068bb2923fdb3195e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
golang: go run go-producer.go | |
redis: redis-server | |
ruby: sidekiq -r './ruby-consumer.rb' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sidekiq' | |
class PrototypeConsumerJob | |
include Sidekiq::Worker | |
def perform(name, other_arg) | |
puts "Received with string '#{name}' and golang timestamp: #{other_arg}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: