Class: Stark::Processor
- Inherits:
-
Object
- Object
- Stark::Processor
- Includes:
- ProtocolHelpers
- Defined in:
- lib/stark/processor.rb
Constant Summary
Constants included from ProtocolHelpers
Stark::ProtocolHelpers::COERCION_FROM_STRING, Stark::ProtocolHelpers::COERCION_TO_STRING, Stark::ProtocolHelpers::THRIFT_TO_RUBY
Instance Method Summary collapse
-
#initialize(handler) ⇒ Processor
constructor
A new instance of Processor.
- #process(iprot, oprot) ⇒ Object
Methods included from ProtocolHelpers
#expect, #expect_list, #expect_map, #expect_set, #hash_cast, #valid_element_type?, #value_for_write
Constructor Details
#initialize(handler) ⇒ Processor
Returns a new instance of Processor.
7 8 9 |
# File 'lib/stark/processor.rb', line 7 def initialize(handler) @handler = handler end |
Instance Method Details
#process(iprot, oprot) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/stark/processor.rb', line 11 def process(iprot, oprot) name, type, seqid = iprot. fail unless type == Thrift::MessageTypes::CALL x = nil if respond_to?("process_#{name}") send("process_#{name}", seqid, iprot, oprot) true else iprot.skip(::Thrift::Types::STRUCT) iprot. x = ::Thrift::ApplicationException.new(Thrift::ApplicationException::UNKNOWN_METHOD, 'Unknown function '+name) false end rescue ::Exception => e Stark.logger.error "#{self.class.name}#process_#{name}: #{e.}\n " + e.backtrace.join("\n ") x = Thrift::ApplicationException.new(Thrift::ApplicationException::INTERNAL_ERROR, e.) false ensure if x oprot.(name, ::Thrift::MessageTypes::EXCEPTION, seqid) x.write(oprot) oprot. oprot.trans.flush end end |