class Thrift::MultiplexedProcessor
Public Class Methods
Source
# File lib/thrift/multiplexed_processor.rb 25 def initialize 26 @actual_processors = {} 27 @default_processor = nil 28 end
Public Instance Methods
Source
# File lib/thrift/multiplexed_processor.rb 38 def process(iprot, oprot) 39 name, type, seqid = iprot.read_message_begin 40 check_type(type) 41 if name.count(":") < 1 42 check_default_processor(name) 43 return @default_processor.process(StoredMessageProtocol.new(iprot, [name, type, seqid]), oprot) 44 end 45 46 service_name, method = name.split(":", 2) 47 processor(service_name).process(StoredMessageProtocol.new(iprot, [method, type, seqid]), oprot) 48 end
Source
# File lib/thrift/multiplexed_processor.rb 34 def register_default(processor) 35 @default_processor = processor 36 end
Source
# File lib/thrift/multiplexed_processor.rb 30 def register_processor(service_name, processor) 31 @actual_processors[service_name] = processor 32 end
Protected Instance Methods
Source
# File lib/thrift/multiplexed_processor.rb 66 def check_default_processor(name) 67 unless @default_processor 68 raise Thrift::Exception.new("Service name not found in message name: #{name}. Did you forget to use a Thrift::Protocol::MultiplexedProtocol in your client?") 69 end 70 end
Source
# File lib/thrift/multiplexed_processor.rb 60 def check_type(type) 61 unless [MessageTypes::CALL, MessageTypes::ONEWAY].include?(type) 62 raise Thrift::Exception.new("This should not have happened!?") 63 end 64 end
Source
# File lib/thrift/multiplexed_processor.rb 52 def processor(service_name) 53 if @actual_processors.has_key?(service_name) 54 @actual_processors[service_name] 55 else 56 raise Thrift::Exception.new("Service name not found: #{service_name}. Did you forget to call #{self.class.name}#register_processor?") 57 end 58 end