Sha256: 0f846c73a2c5b63e814f33b85faafd5ce6bcebbe23cea7a61953a4e73a8a30de

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

require_relative "chaotic_job/version"
require_relative "chaotic_job/journal"
require_relative "chaotic_job/performer"
require_relative "chaotic_job/glitch"
require_relative "chaotic_job/scenario"
require_relative "chaotic_job/simulation"

module ChaoticJob
  class RetryableError < StandardError
  end

  module Helpers
    def perform_all
      Performer.perform_all
    end

    def perform_all_within(time)
      Performer.perform_all_within(time)
    end

    def perform_all_before(time)
      Performer.perform_all_before(time)
    end

    def perform_all_after(time)
      Performer.perform_all_after(time)
    end

    def run_simulation(job, depth: nil, variations: nil, &block)
      seed = defined?(RSpec) ? RSpec.configuration.seed : Minitest.seed
      kwargs = {test: self, seed: seed}
      kwargs[:depth] = depth if depth
      kwargs[:variations] = variations if variations
      Simulation.new(job, **kwargs).run(&block)
    end

    def run_scenario(job, glitch: nil, glitches: nil, raise: nil, capture: nil)
      kwargs = {glitches: glitches || [glitch]}
      kwargs[:raise] = raise if raise
      kwargs[:capture] = capture if capture
      Scenario.new(job, **kwargs).run
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chaotic_job-0.1.0 lib/chaotic_job.rb