Class: Rocketman::Relay::Redis

Inherits:
Object
  • Object
show all
Includes:
Producer
Defined in:
lib/rocketman/relay/redis.rb

Instance Method Summary collapse

Methods included from Producer

#emit

Instance Method Details

#start(service) ⇒ Object

You should always pass in a new, dedicated connection to Redis. This is because redis.psubscribe will hog the whole Redis connection, thus if you pass in an existing Redis connection, you won’t be able to do anything with that connection anymore.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rocketman/relay/redis.rb', line 10

def start(service)
  puts "Rocketman> Using Redis as external producer".freeze if Rocketman.configuration.debug

  Thread.abort_on_exception = Rocketman.configuration.debug
  Thread.new do
    service.psubscribe("*") do |on|
      on.pmessage do |_pattern, event, payload|
        emit(event, payload)
      end
    end
  end
end