Sha256: b47134c43d3fd1b4799e51081ddb2eb1a9a15bc941ec2bfefb493e1115a61f90

Contents?: true

Size: 1.14 KB

Versions: 36

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require 'semaphore'

module RubyRabbitmqJanus
  module Rabbit
    # Define an module for create an publisher
    module Publisher
      # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>

      # # Parent class for all publisher
      # This element send and read a message in rabbitmq Queue
      #
      # @!attribute [r] response
      #   @return [RubyRabbitmqJanus::Janus::Responses::Response]
      #     Given a Janus response
      #
      # @abstract Publish message in RabbitMQ
      class BasePublisher
        attr_reader :responses

        # Define a base publisher
        def initialize
          @responses = []
          @semaphore = Semaphore.new
          @lock = Mutex.new
        rescue
          raise Errors::Rabbit::BasePublisher::Initialize
        end

        private

        attr_accessor :semaphore, :lock

        def return_response
          @semaphore.wait
          response = nil
          @lock.synchronize do
            response = @responses.shift
          end
          response
        end
      end
    end
  end
end

require 'rrj/rabbit/publish/publisher'
require 'rrj/rabbit/publish/listener'

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-2.3.1.pre.201 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.3.1.pre.198 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.3.0.pre.197 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.3.0.pre.196 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.3.0 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.3.0.pre.194 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.3.0.pre.192 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.3.0.pre.170 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.2.2 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.2.1 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.2.1.pre.181 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.2.1.pre.180 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.2.0.pre.179 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.2.0 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.2.0.pre.177 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.2.0.pre.173 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.2.0.pre.170 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.2.0.pre.168 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.2.0.pre.167 lib/rrj/rabbit/publish/base_publisher.rb
ruby_rabbitmq_janus-2.2.0.pre.166 lib/rrj/rabbit/publish/base_publisher.rb