Skip to content

Instantly share code, notes, and snippets.

@joshjordan
Last active April 26, 2018 12:46
Show Gist options
  • Save joshjordan/6415337e8a75fa068bb2923fdb3195e9 to your computer and use it in GitHub Desktop.
Save joshjordan/6415337e8a75fa068bb2923fdb3195e9 to your computer and use it in GitHub Desktop.

Revisions

  1. joshjordan revised this gist Apr 26, 2018. 1 changed file with 0 additions and 0 deletions.
    Binary file removed dump.rdb
    Binary file not shown.
  2. joshjordan revised this gist Apr 26, 2018. 3 changed files with 7 additions and 18 deletions.
    Binary file modified dump.rdb
    Binary file not shown.
    17 changes: 6 additions & 11 deletions go-producer.go
    Original file line number Diff line number Diff line change
    @@ -7,11 +7,6 @@ import (
    "github.com/jrallison/go-workers"
    )

    //todo: does job name need to match?
    func PrototypeConsumerJob(message *workers.Msg) {}

    type myMiddleware struct{}

    func main() {
    workers.Configure(map[string]string{
    "server": "localhost:6379",
    @@ -21,24 +16,24 @@ func main() {
    })

    fmt.Println("Enqueuing a job...")
    workers.Enqueue("myqueue3", "Add", []string{"Bill", "Other thing"})
    workers.Enqueue("default", "PrototypeConsumerJob", []string{"Bill", time.Now().String()})
    time.Sleep(1000 * time.Millisecond)

    fmt.Println("Enqueuing a job...")
    workers.Enqueue("myqueue3", "Add", []string{"Bob", "Other thing"})
    workers.Enqueue("default", "PrototypeConsumerJob", []string{"Bob", time.Now().String()})
    time.Sleep(1000 * time.Millisecond)

    fmt.Println("Enqueuing a job...")
    workers.Enqueue("myqueue3", "Add", []string{"Norbert", "Other thing"})
    workers.Enqueue("default", "PrototypeConsumerJob", []string{"Norbert", time.Now().String()})
    time.Sleep(1000 * time.Millisecond)

    fmt.Println("Enqueuing a job...")
    workers.Enqueue("myqueue3", "Add", []string{"Sherbert", "Other thing"})
    workers.Enqueue("default", "PrototypeConsumerJob", []string{"Sherbert", time.Now().String()})
    time.Sleep(1000 * time.Millisecond)

    fmt.Println("Enqueuing a job...")
    workers.Enqueue("myqueue3", "Add", []string{"Batman", "Other thing"})
    workers.Enqueue("default", "PrototypeConsumerJob", []string{"Batman", time.Now().String()})

    fmt.Println("Waiting for ruby to pick them up...")
    fmt.Println("Waiting for ruby to process jobs...")
    time.Sleep(10 * time.Minute)
    }
    8 changes: 1 addition & 7 deletions ruby-consumer.rb
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,9 @@
    require 'sidekiq'



    # Sidekiq.configure_server do |config|
    # config.redis = { :namespace => 'other-stuff-filewatcher', :size => 1, :url => 'redis://127.0.0.1:6379'}
    # end

    class PrototypeConsumerJob
    include Sidekiq::Worker

    def perform(name, other_arg)
    puts "Received job #{name} with arg: #{other_arg}"
    puts "Received with string '#{name}' and golang timestamp: #{other_arg}"
    end
    end
  3. joshjordan created this gist Apr 26, 2018.
    3 changes: 3 additions & 0 deletions Procfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    golang: go run go-producer.go
    redis: redis-server
    ruby: sidekiq -r './ruby-consumer.rb'
    Binary file added dump.rdb
    Binary file not shown.
    44 changes: 44 additions & 0 deletions go-producer.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    package main

    import (
    "fmt"
    "time"

    "github.com/jrallison/go-workers"
    )

    //todo: does job name need to match?
    func PrototypeConsumerJob(message *workers.Msg) {}

    type myMiddleware struct{}

    func main() {
    workers.Configure(map[string]string{
    "server": "localhost:6379",
    "database": "0",
    "pool": "30",
    "process": "1",
    })

    fmt.Println("Enqueuing a job...")
    workers.Enqueue("myqueue3", "Add", []string{"Bill", "Other thing"})
    time.Sleep(1000 * time.Millisecond)

    fmt.Println("Enqueuing a job...")
    workers.Enqueue("myqueue3", "Add", []string{"Bob", "Other thing"})
    time.Sleep(1000 * time.Millisecond)

    fmt.Println("Enqueuing a job...")
    workers.Enqueue("myqueue3", "Add", []string{"Norbert", "Other thing"})
    time.Sleep(1000 * time.Millisecond)

    fmt.Println("Enqueuing a job...")
    workers.Enqueue("myqueue3", "Add", []string{"Sherbert", "Other thing"})
    time.Sleep(1000 * time.Millisecond)

    fmt.Println("Enqueuing a job...")
    workers.Enqueue("myqueue3", "Add", []string{"Batman", "Other thing"})

    fmt.Println("Waiting for ruby to pick them up...")
    time.Sleep(10 * time.Minute)
    }
    15 changes: 15 additions & 0 deletions ruby-consumer.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    require 'sidekiq'



    # Sidekiq.configure_server do |config|
    # config.redis = { :namespace => 'other-stuff-filewatcher', :size => 1, :url => 'redis://127.0.0.1:6379'}
    # end

    class PrototypeConsumerJob
    include Sidekiq::Worker

    def perform(name, other_arg)
    puts "Received job #{name} with arg: #{other_arg}"
    end
    end