Sha256: 5ef88c006c0d450de1cd4aea2223dde2d62b7ec7115910196cbe67cb4d82ac8e

Contents?: true

Size: 597 Bytes

Versions: 2

Compression:

Stored size: 597 Bytes

Contents

require "securerandom"
require "message_queue/options_helper"

module MessageQueue
  class Producer
    include OptionsHelper

    attr_reader :connection, :options

    def initialize(connection, options = {})
      @connection = connection
      @options = deep_clone(options)
    end

    def dump_object(object)
      connection.serializer.dump(object)
    end

    def default_options
      { :content_type => connection.serializer.content_type, :timestamp => Time.now.utc.to_i, :message_id => generate_id }
    end

    private

    def generate_id
      SecureRandom.uuid
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
message_queue-0.1.1 lib/message_queue/producer.rb
message_queue-0.1.0 lib/message_queue/producer.rb