Sha256: 0195f34bcbe6491aa43efa1f440d4f4971f7a5afbe1a147f4164b292e31afff0

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

module ActiveHook
  module Server
    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 = {
        workers: 2,
        queue_threads: 2,
        retry_threads: 1,
        redis_url: ENV['REDIS_URL'],
        redis_pool: 5,
        signature_header: 'X-Webhook-Signature'
      }.freeze

      attr_accessor :workers, :queue_threads, :retry_threads,
                    :redis_url, :redis_pool, :signature_header

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

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

      def manager_options
        {
          workers: workers,
          options: worker_options
        }
      end

      def redis
        {
          size: redis_pool,
          url: redis_url
        }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activehook-server-0.1.5 lib/activehook/server/config.rb
activehook-server-0.1.4 lib/activehook/server/config.rb
activehook-server-0.1.3 lib/activehook/server/config.rb
activehook-server-0.1.2 lib/activehook/server/config.rb
activehook-server-0.1.1 lib/activehook/server/config.rb
activehook-server-0.1.0 lib/activehook/server/config.rb