Sha256: 06d9e4a48d4b7b8b669f6721de4cac62737be16bd04693e88c09741a116688ae

Contents?: true

Size: 614 Bytes

Versions: 2

Compression:

Stored size: 614 Bytes

Contents

$:.unshift File.dirname(__FILE__)+"/../../lib/"
require 'magent'

Magent.push("/errors", :fail, "this is a fail")

class Error
  include Magent::Actor

  channel_name "errors"
  expose :fail

  def fail(payload)
    @count ||= 0
    errors = self.class.channel.errors

    errors.each do |error|
      @count += 1
      $stderr.puts "Retrying: #{error["method"]}(#{error["payload"].inspect})"
      self.class.channel.retry_error(error)
    end

    if @count == 0
      raise payload.inspect
    end
  end
end

Magent.register(Error.new)

if $0 == __FILE__
  Magent::Processor.new(Magent.current_actor).run!
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
magent-0.2 examples/error/error.rb
magent-0.1.3 examples/error/error.rb