Sha256: eaa0d7f9a59cc879802a82929f9091c07330f3447827f5c39e677228ca02cb04
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
require 'celluloid/current' module GBDispatch class Runner include Celluloid # Execute given block. # If there is an exception thrown, it log it and crash actor. # For more information about error handling, check Celluloid documentation. # @param block [Proc] # @param options [Hash] # @option options [Proc] :condition celluloid condition block called on finish with result # @option options [String] :name queue name used for debugging and better logging. def execute(block, options=Hash.new) begin condition = options[:condition] result = block.call condition.call(result) if condition result rescue Exception => e name = options[:name] if defined?(Opbeat) Opbeat.set_context extra: {queue: name} if name Opbeat.capture_exception(e) end Celluloid.logger.error "Failed execution of queue #{name} with error #{e.message}" condition.call(e) if condition raise e end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gb_dispatch-0.0.4 | lib/gb_dispatch/runner.rb |