Sha256: f18efcdb92622ea183f007605fa0261338f9f7165875a17f01ea9b9e322506f3

Contents?: true

Size: 1.05 KB

Versions: 6

Compression:

Stored size: 1.05 KB

Contents

require "logger"

require "racecar/instrumenter"
require "racecar/null_instrumenter"
require "racecar/consumer"
require "racecar/consumer_set"
require "racecar/runner"
require "racecar/config"
require "ensure_hash_compact"

module Racecar
  class Error < StandardError
  end

  class ConfigError < Error
  end

  def self.config
    @config ||= Config.new
  end

  def self.config=(config)
    @config = config
  end

  def self.configure
    yield config
  end

  def self.logger
    config.logger
  end

  def self.logger=(logger)
    config.logger = logger
  end

  def self.instrumenter
    @instrumenter ||= begin
      default_payload = { client_id: config.client_id, group_id: config.group_id }

      Instrumenter.new(default_payload).tap do |instrumenter|
        if instrumenter.backend == NullInstrumenter
          logger.warn "ActiveSupport::Notifications not available, instrumentation is disabled"
        end
      end
    end
  end

  def self.run(processor)
    Runner.new(processor, config: config, logger: logger, instrumenter: instrumenter).run
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
racecar-2.0.0 lib/racecar.rb
racecar-2.0.0.beta6 lib/racecar.rb
racecar-2.0.0.beta5 lib/racecar.rb
racecar-2.0.0.beta4 lib/racecar.rb
racecar-2.0.0.beta3 lib/racecar.rb
racecar-2.0.0.beta2 lib/racecar.rb