Sha256: e48184578b84900177f7788ef026d2b478065adc1821d5349e1d225cc5f13be4

Contents?: true

Size: 619 Bytes

Versions: 1

Compression:

Stored size: 619 Bytes

Contents

module Waffle
  module Transports
    class Redis < Base
      attr_reader :db

      def publish(flow = 'events', message = '')
        db.publish(flow, Waffle.encoder.encode(message))
      end

      def subscribe(flow = 'events')
        db.subscribe(*flow) do |on|
          on.message do |channel, message|
            yield(channel, Waffle.encoder.decode(message))
          end
        end
      end

      def connection_exceptions
        [Errno::ECONNREFUSED, Errno::ECONNRESET]
      end

      protected
      def do_connect
        @db = ::Redis.new(:url => Waffle.config.url)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
waffle-0.4.0 lib/waffle/transports/redis.rb