Sha256: e1f2d583566c48f5adfb3ebb472cf571d6cdff2499b9a7da5e31d4803f92d4cb

Contents?: true

Size: 781 Bytes

Versions: 1

Compression:

Stored size: 781 Bytes

Contents

require 'redis'

module Rocketman
  module Relay
    class Redis
      include Rocketman::Producer

      # 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.
      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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rocketman-0.3.0 lib/rocketman/relay/redis.rb