Sha256: 7dccb155be86e6e2cd90cbc4a69712ef8082f59738b7416e4ffbd76727acb043

Contents?: true

Size: 1.48 KB

Versions: 9

Compression:

Stored size: 1.48 KB

Contents

require 'oj'

module RabbitWQ
  class Configuration

    def self.attributes
      %w(
        delayed_exchange_prefix
        delayed_queue_prefix
        environment_file_path
        env
        error_queue
        threads
        time_zone
        work_exchange
        work_exchange_type
        work_log_level
        work_log_path
        work_publish_queue
        work_subscribe_queue
      )
    end

    attr_accessor( *attributes )

    def self.from_file( file_path )
      options = Oj.load( File.read( file_path ))
      RabbitWQ.configuration = Configuration.new

      attributes.each do |c|
        if options[c]
          RabbitWQ.configuration.send( :"#{c}=", options[c] )
        end
      end
    end

    def delayed_exchange_prefix
      @delayed_exchange_prefix || 'work-delay'
    end

    def delayed_queue_prefix
      @delayed_queue_prefix || 'work-delay'
    end

    def env
      @env || 'production'
    end

    def error_queue
      @error_queue || 'work-error'
    end

    def time_zone
      @time_zone || 'UTC'
    end

    def work_exchange
      @work_exchange || 'work'
    end

    def work_exchange_type
      @work_exchange_type || 'fanout'
    end

    def work_log_level
      @work_log_level || 'info'
    end

    def work_log_path
      @work_log_path || '/var/log/rabbit-wq/rabbit-wq-work.log'
    end

    def work_publish_queue
      @work_publish_queue || 'work'
    end

    def work_subscribe_queue
      @work_subscribe_queue || 'work'
    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rabbit-wq-1.9.0 lib/rabbit_wq/configuration.rb
rabbit-wq-1.8.0 lib/rabbit_wq/configuration.rb
rabbit-wq-1.7.0 lib/rabbit_wq/configuration.rb
rabbit-wq-1.6.3 lib/rabbit_wq/configuration.rb
rabbit-wq-1.6.2 lib/rabbit_wq/configuration.rb
rabbit-wq-1.6.1 lib/rabbit_wq/configuration.rb
rabbit-wq-1.6.0 lib/rabbit_wq/configuration.rb
rabbit-wq-1.5.0 lib/rabbit_wq/configuration.rb
rabbit-wq-1.4.0 lib/rabbit_wq/configuration.rb