Sha256: c51f83dd1cdd66bd7d08fed76c29b9985e862ca946925c39a863b138f493cf23

Contents?: true

Size: 1.16 KB

Versions: 15

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

module RubyRabbitmqJanus
  module Janus
    module Transactions
      # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
      #
      # # Manage a transaction
      #
      # Manage a transaction with message if contains a session identifier
      class Session < Transaction
        # Initialize a transaction with handle
        #
        # @param [Fixnum] session
        #   Use a session identifier for created message
        def initialize(exclusive, session)
          super(session)
          @exclusive = exclusive
        end

        # Opening a short transaction with rabbitmq and close when is ending
        #
        # @yield Send a message to Janus
        def connect
          rabbit.transaction_short do
            choose_queue
            yield
          end
        end

        def publish_message(type, options = {})
          msg = Janus::Messages::Standard.new(type, opts.merge!(options))
          response = read_response(publisher.publish(msg))
          Janus::Responses::Standard.new(response)
        end

        private

        def opts
          { 'session_id' => session }
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-3.0.0.pre.366 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-3.0.0.pre.364 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-3.0.0.pre.358 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-3.0.0.pre.354 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-3.0.0.pre.352 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-3.0.0.pre.351 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-2.0.0.pre.108 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-2.0.0 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-2.0.0.pre.106 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-2.0.0.pre.101 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-2.0.0.pre.100 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-2.0.0.pre.97 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-2.0.0.pre.96 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-2.0.0.pre.95 lib/rrj/janus/transactions/session.rb
ruby_rabbitmq_janus-2.0.0.pre.42 lib/rrj/janus/transactions/session.rb