Sha256: e74597147c5dbc5eafb088580c51d417b42007323e35d5d25bfbf2a08d3c9d37
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true # Scenario.new(job).run { |scenario| ... } # Scenario.new(job).all_glitched? module ChaoticJob class Scenario attr_reader :events def initialize(job, glitches:, raise: RetryableError, capture: /active_job/) @job = job @glitches = glitches @raise = raise @capture = capture @glitch = nil @events = [] end def run @job.class.retry_on RetryableError, attempts: 10, wait: 1, jitter: 0 ActiveSupport::Notifications.subscribed(->(event) { @events << event.dup }, @capture) do glitch.inject! do if block_given? yield else @job.enqueue Performer.perform_all end end end # TODO: assert that all glitches ran end def to_s @glitches.map { |position, location| "#{position}-#{location}" }.join("|>") end def all_glitched? @glitch.all_executed? end private def glitch @glitch ||= Glitch.new.tap do |glitch| @glitches.each do |position, location, _description| glitch.public_send(position, location) { raise @raise } end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chaotic_job-0.1.0 | lib/chaotic_job/scenario.rb |