diff options
author | James E. King, III <jking@apache.org> | 2017-11-18 22:37:54 -0500 |
---|---|---|
committer | James E. King, III <jking@apache.org> | 2017-11-21 14:20:26 -0500 |
commit | 20e16bc6a41c6faead040aed7f3c00b9d2e7f842 (patch) | |
tree | f8abb950b1ad7ef652840298523b8ec9baa6ce4f /lib/perl | |
parent | cde4d4181a252323d87e7ac086ce495cd1227c5c (diff) | |
download | thrift-20e16bc6a41c6faead040aed7f3c00b9d2e7f842.tar.gz |
THRIFT-2013: add perl crosstest multiplexed client and server logic
Client: perl
This closes #1416
Diffstat (limited to 'lib/perl')
-rw-r--r-- | lib/perl/lib/Thrift/MultiplexedProcessor.pm | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/perl/lib/Thrift/MultiplexedProcessor.pm b/lib/perl/lib/Thrift/MultiplexedProcessor.pm index 6629c0bb1..05c4ead9c 100644 --- a/lib/perl/lib/Thrift/MultiplexedProcessor.pm +++ b/lib/perl/lib/Thrift/MultiplexedProcessor.pm @@ -66,10 +66,18 @@ sub new { my $self = {}; $self->{serviceProcessorMap} = {}; + $self->{defaultProcessor} = undef; return bless($self,$classname); } +sub defaultProcessor { + my $self = shift; + my $processor = shift; + + $self->{defaultProcessor} = $processor; +} + sub registerProcessor { my $self = shift; my $serviceName = shift; @@ -98,8 +106,14 @@ sub process { # Extract the service name and the new Message name. if (index($fname, Thrift::MultiplexedProtocol::SEPARATOR) == -1) { - die new Thrift::TException("Service name not found in message name: {$fname}. Did you " . - "forget to use a MultiplexProtocol in your client?"); + if (defined $self->{defaultProcessor}) { + return $self->{defaultProcessor}->process( + new Thrift::StoredMessageProtocol($input, $fname, $mtype, $rseqid), $output + ); + } else { + die new Thrift::TException("Service name not found in message name: {$fname} and no default processor defined. Did you " . + "forget to use a MultiplexProtocol in your client?"); + } } (my $serviceName, my $messageName) = split(':', $fname, 2); @@ -109,11 +123,11 @@ sub process { "to call registerProcessor()?"); } - # Dispatch processing to the stored processor - my $processor = $self->{serviceProcessorMap}->{$serviceName}; - return $processor->process( + # Dispatch processing to the stored processor + my $processor = $self->{serviceProcessorMap}->{$serviceName}; + return $processor->process( new Thrift::StoredMessageProtocol($input, $messageName, $mtype, $rseqid), $output - ); + ); } 1; |