Sha256: 041a7b1b68f4326fbf77839acb50d3a0bc83b1aacf94b7b29aad1026cf84a1d8

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true
# :reek:InstanceVariableAssumption and :reek:NilCheck
# :reek:TooManyInstanceVariables and :reek:TooManyStatements

module RubyRabbitmqJanus
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
  module Janus
    module Concurrencies
      # For listen standard queue ("from-janus" by default)
      class Event < Concurrency
        include Singleton

        # Initialize Event object. Is used for listen an standard out queue to Janus
        def initialize
          super
          @publish = @response = nil
        end

        # Execute an block code in a thread
        def run(&block)
          @thread.join
          Thread.new do
            loop { @thread.thread_variable_get(:publish).listen_events(&block) }
          end
        end

        private

        # Initialize a thread
        def transaction_running
          Thread.current.thread_variable_set(:publish,
                                             Rabbit::Publisher::Listener.new(rabbit))
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-1.1.9 lib/rrj/janus/processus/event.rb
ruby_rabbitmq_janus-1.1.8 lib/rrj/janus/processus/event.rb
ruby_rabbitmq_janus-1.1.7 lib/rrj/janus/processus/event.rb
ruby_rabbitmq_janus-1.1.6 lib/rrj/janus/processus/event.rb
ruby_rabbitmq_janus-1.1.5 lib/rrj/janus/processus/event.rb
ruby_rabbitmq_janus-1.1.4 lib/rrj/janus/processus/event.rb
ruby_rabbitmq_janus-1.1.3 lib/rrj/janus/processus/event.rb
ruby_rabbitmq_janus-1.1.2 lib/rrj/janus/processus/event.rb