Sha256: 487fd2b38075516c5f44a94b1404528bee55aff3f5ba240c6f46f154f2f273a4

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 KB

Contents

require 'logger'
require 'forwardable'
require 'yaml'
require 'bunny'
require 'jackhammer/version'
require 'jackhammer/exceptions'
require 'jackhammer/log'
require 'jackhammer/configuration'
require 'jackhammer/message_receiver'
require 'jackhammer/queue_name'
require 'jackhammer/queue'
require 'jackhammer/topic'
require 'jackhammer/topic_manager'
require 'jackhammer/server'

module Jackhammer
  class << self
    attr_accessor :configuration
    attr_writer :connection

    def configure
      @configuration = Configuration.instance
      yield @configuration
    end

    def connection
      @connection ||= Bunny.new(
        Jackhammer.configuration.connection_url,
        Jackhammer.configuration.connection_options
      ).start
    end

    def channel
      @channel ||= connection.create_channel
    end

    def topics
      @topics ||= TopicManager.topics
    end

    def publish_options(options = {}, time = Time.now.utc)
      configuration.publish_options.dup.merge(options).tap do |opts|
        opts[:timestamp] = time.to_i
        opts[:app_id] ||= configuration.app_name
        opts[:headers] ||= {}
        opts[:headers][:time] ||= time.iso8601
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
jackhammer-1.3.7 lib/jackhammer.rb
jackhammer-1.3.6 lib/jackhammer.rb
jackhammer-1.3.5 lib/jackhammer.rb
jackhammer-1.3.4 lib/jackhammer.rb
jackhammer-1.3.3 lib/jackhammer.rb
jackhammer-1.3.2 lib/jackhammer.rb
jackhammer-1.3.1 lib/jackhammer.rb