Sha256: 3d6c9807ddfbcd311d2b96796c5811aea84b6da0916924f190f1edfb31025247

Contents?: true

Size: 1.31 KB

Versions: 14

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require "logger"

require "racecar/instrumenter"
require "racecar/null_instrumenter"
require "racecar/consumer"
require "racecar/consumer_set"
require "racecar/runner"
require "racecar/parallel_runner"
require "racecar/config"
require "racecar/version"
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 = Runner.new(processor, config: config, logger: logger, instrumenter: instrumenter)

    if config.parallel_workers && config.parallel_workers > 1
      ParallelRunner.new(runner: runner, config: config, logger: logger).run
    else
      runner.run
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
racecar-2.8.2 lib/racecar.rb
racecar-2.8.2.beta lib/racecar.rb
racecar-2.8.1 lib/racecar.rb
racecar-2.8.0.rc.1 lib/racecar.rb
racecar-2.8.0.beta.2 lib/racecar.rb
racecar-2.8.0.beta.1 lib/racecar.rb
racecar-2.7.0 lib/racecar.rb
racecar-2.7.0.beta1 lib/racecar.rb
racecar-2.6.0 lib/racecar.rb
racecar-2.5.0 lib/racecar.rb
racecar-2.4.0 lib/racecar.rb
racecar-2.3.1 lib/racecar.rb
racecar-2.3.0 lib/racecar.rb
racecar-2.3.0.alpha1 lib/racecar.rb