Module: Tobox

Defined in:
lib/tobox.rb,
lib/tobox/cli.rb,
lib/tobox/pool.rb,
lib/tobox/worker.rb,
lib/tobox/fetcher.rb,
lib/tobox/version.rb,
lib/tobox/application.rb,
lib/tobox/configuration.rb,
lib/tobox/plugins/inbox.rb,
lib/tobox/plugins/stats.rb,
lib/tobox/plugins/sentry.rb,
lib/tobox/plugins/datadog.rb,
lib/tobox/pool/fiber_pool.rb,
lib/tobox/plugins/progress.rb,
lib/tobox/plugins/zeitwerk.rb,
lib/tobox/pool/threaded_pool.rb,
lib/tobox/plugins/event_grouping.rb

Defined Under Namespace

Modules: Plugins Classes: Application, CLI, Configuration, Error, Fetcher, FiberPool, KillError, Pool, ThreadedPool, Worker

Constant Summary collapse

EMPTY =
[].freeze
VERSION =
"0.6.1"

Class Method Summary collapse

Class Method Details

.raise_batch_errors(batch_errors) ⇒ Object

when using batch sizes higher than 1, this method can be used to signal multiple errors for a subset of the events which may have failed processing; these events are identified by the index inside the batch.

on(:event_type) do |*events|
  successful, failed = handle_event_batch(events)

  deal_with_success(successful)

  batch_errors = failed.to_h do |failed_event|
    [
       events.index(failed_event),
       MyException.new("failed handling process batch")
    ]
  end

  Tobox.raise_batch_error(batch_errors)
end


56
57
58
59
60
61
62
# File 'lib/tobox.rb', line 56

def self.raise_batch_errors(batch_errors)
  unless batch_errors.respond_to?(:to_hash) && batch_errors.all? { |k, v| k.is_a?(Integer) && v.is_a?(Exception) }
    raise "batch errors must be an array of index-to-exception tuples"
  end

  throw(:tobox_batch_errors, batch_errors.to_h)
end