Sha256: 01be21413e4f6f72d3ec1a21a745405b11da0ac62c34bf34142d66ee05d11fbe
Contents?: true
Size: 1.92 KB
Versions: 2
Compression:
Stored size: 1.92 KB
Contents
# frozen_string_literal: true require "sequel" require_relative "tobox/version" require "mutex_m" module Tobox class Error < StandardError; end EMPTY = [].freeze module Plugins @plugins = {} @plugins.extend(Mutex_m) # Loads a plugin based on a name. If the plugin hasn't been loaded, tries to load # it from the load path under "httpx/plugins/" directory. # def self.load_plugin(name) h = @plugins unless (plugin = h.synchronize { h[name] }) require "tobox/plugins/#{name}" raise "Plugin #{name} hasn't been registered" unless (plugin = h.synchronize { h[name] }) end plugin end # Registers a plugin (+mod+) in the central store indexed by +name+. # def self.register_plugin(name, mod) h = @plugins h.synchronize { h[name] = mod } end end # 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 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 end require_relative "tobox/fetcher" require_relative "tobox/worker" require_relative "tobox/pool" require_relative "tobox/application" require_relative "tobox/configuration"
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tobox-0.6.1 | lib/tobox.rb |
tobox-0.6.0 | lib/tobox.rb |