module MyStuff::Fb303::ResilientProcessor

Public Class Methods

extended(other) click to toggle source
# File lib/my_stuff/fb303/resilient_processor.rb, line 55
def self.extended other
  class <<other
    alias :unresilient_process :process
    alias :process :resilient_process
  end
end

Public Instance Methods

resilient_process(iprot, oprot) click to toggle source
# File lib/my_stuff/fb303/resilient_processor.rb, line 36
def resilient_process iprot, oprot
  spy = SpyIProt.new(iprot)
  name, type, seqid = spy.read_message_begin

  begin
    unresilient_process(spy, oprot)
  rescue => e
    ae = Thrift::ApplicationException.new(
      Thrift::ApplicationException::UNKNOWN,
      e.inspect
    )
    oprot.write_message_begin(name, Thrift::MessageTypes::EXCEPTION, seqid)
    ae.write oprot
    oprot.write_message_end
    oprot.trans.flush
    false
  end
end