Sha256: 773682f118cade96bd59b2b2fcfe45a84ca36d1a87351ee5c5bfb0bc2dab303a
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
require 'celluloid' 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gb_dispatch-0.0.3 | lib/gb_dispatch/runner.rb |
gb_dispatch-0.0.2 | lib/gb_dispatch/runner.rb |
gb_dispatch-0.0.1 | lib/gb_dispatch/runner.rb |