Sha256: de805e411a6c71751bcf24524b14306048a1199d679c81182e2710213adf61c0

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

module MessageDriver
  module Destination
    class Base
      attr_reader :adapter, :name, :dest_options, :message_props

      def initialize(adapter, name, dest_options, message_props)
        @adapter = adapter
        @name = name
        @dest_options = dest_options
        @message_props = message_props
      end

      def publish(body, headers = {}, properties = {})
        current_adapter_context.publish(self, body, headers, properties)
      end

      def pop_message(options = {})
        current_adapter_context.pop_message(self, options)
      end

      def after_initialize(_adapter_context)
        # does nothing, feel free to override as needed
      end

      def message_count
        fail "#message_count is not supported by #{self.class}"
      end

      def subscribe(_options = {}, &_consumer)
        fail "#subscribe is not supported by #{self.class}"
      end

      def consumer_count
        fail "#consumer_count is not supported by #{self.class}"
      end

      def middleware
        @middleware ||= Middleware::MiddlewareStack.new(self)
      end

      private

      def current_adapter_context
        adapter.broker.client.current_adapter_context
      end

      def client
        @client ||= adapter.broker.client
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
message-driver-0.6.1 lib/message_driver/destination.rb
message-driver-0.6.0 lib/message_driver/destination.rb
message-driver-0.5.3 lib/message_driver/destination.rb
message-driver-0.5.2 lib/message_driver/destination.rb
message-driver-0.5.1 lib/message_driver/destination.rb
message-driver-0.5.0 lib/message_driver/destination.rb