Sha256: af9c7d3b0aac8f07a32e6714e48460298ef3729f97d6076240b79690289c6fa3

Contents?: true

Size: 896 Bytes

Versions: 1

Compression:

Stored size: 896 Bytes

Contents

module ActiveHook
  class << self
    def configure
      reset
      yield(config)
    end

    def config
      @config ||= Config.new
    end

    def reset
      @config = nil
      @connection_pool = nil
    end
  end

  class Config
    DEFAULTS = {
      redis_url: ENV['REDIS_URL'],
      redis_pool: 5,
      workers: 2,
      queue_threads: 4,
      retry_threads: 2,
      retry_max: 3,
      retry_time: 3600,
    }.freeze

    attr_accessor :redis_url, :redis_pool, :retry_max, :retry_time,
                  :workers, :queue_threads, :retry_threads

    def initialize
      DEFAULTS.each { |key, value| send("#{key}=", value) }
    end

    def retry_max_time
      @retry_max_time ||= retry_max * retry_time
    end

    def worker_options
      {
        worker_count: workers,
        queue_threads: queue_threads,
        retry_threads: retry_threads
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activehook-0.1.0 lib/activehook/config.rb