Sha256: 9078bfaaa7a4574169e187005215cdc3c7669d0fa841c5acdd306608d996336d

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 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
          publisher = Rabbit::Publisher::Listener.new(rabbit)
          Thread.current.thread_variable_set(:publish, publisher)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-1.1.12 lib/rrj/janus/processus/event.rb
ruby_rabbitmq_janus-1.1.11 lib/rrj/janus/processus/event.rb
ruby_rabbitmq_janus-1.1.10 lib/rrj/janus/processus/event.rb