Sha256: 8d29cb7f49f7960cc778961250d578abb179fec8cb94bda93f291a2fce06f51d

Contents?: true

Size: 895 Bytes

Versions: 5

Compression:

Stored size: 895 Bytes

Contents

require "logger"

require "racecar/consumer"
require "racecar/runner"
require "racecar/config"

module Racecar
  # Ignores all instrumentation events.
  class NullInstrumenter
    def self.instrument(*)
      yield if block_given?
    end
  end

  class Error < StandardError
  end

  class ConfigError < Error
  end

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

  def self.configure
    yield config
  end

  def self.logger
    @logger ||= Logger.new(STDOUT)
  end

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

  def self.instrumenter
    require "active_support/notifications"

    ActiveSupport::Notifications
  rescue LoadError
    logger.warn "ActiveSupport::Notifications not available, instrumentation is disabled"

    NullInstrumenter
  end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
racecar-0.4.0.beta1 lib/racecar.rb
racecar-0.3.8 lib/racecar.rb
racecar-0.3.7 lib/racecar.rb
racecar-0.3.6 lib/racecar.rb
racecar-0.3.5 lib/racecar.rb