Net-AMQP-0.06~dfsg/0000755000000000000000000000000012172762655012476 5ustar rootrootNet-AMQP-0.06~dfsg/t/0000755000000000000000000000000012140350635012723 5ustar rootrootNet-AMQP-0.06~dfsg/t/04_table.t0000444000000000000000000000427512140350635014510 0ustar rootrootuse strict; use warnings; use FindBin; use Test::More; BEGIN { use_ok('Net::AMQP'); use_ok('Net::AMQP::Common', ':all'); } Net::AMQP::Protocol->load_xml_spec($FindBin::Bin . '/../spec/amqp0-10.xml'); my $pkey = pack_short_string('k'); sub pft { substr pack_field_table({ k => shift }), 4 } # strip overall length is(pft( 'x' ), $pkey.'S'.pack_long_string('x')); is(pft( '1' ), $pkey.'I'.pack_long_integer(1)); is(pft( '-1' ), $pkey.'I'.pack_long_integer(-1)); is(pft( ' 1' ), $pkey.'S'.pack_long_string(' 1')); is(pft( Net::AMQP::Value::String->new(1) ), $pkey.'S'.pack_long_string('1')); is(pft( Net::AMQP::Value::Integer->new(' 1') ), $pkey.'I'.pack_long_integer(1)); is(pft( Net::AMQP::Value::Integer->new(' -1') ), $pkey.'I'.pack_long_integer(-1)); is(pft( Net::AMQP::Value::Integer->new(4.2) ), $pkey.'I'.pack_long_integer(4)); is(pft( Net::AMQP::Value::Timestamp->new(1) ), $pkey.'T'.pack_timestamp(1)); is(pft( Net::AMQP::Value::Boolean->new(1) ), $pkey.'t'.pack_boolean(1)); is(pft( Net::AMQP::Value::true ), $pkey.'t'.pack_boolean(1)); is(pft( Net::AMQP::Value::false ), $pkey.'t'.pack_boolean(0)); # overloading my $hi = Net::AMQP::Value::String->new("hi"); my $four = Net::AMQP::Value::Integer->new(4.2); my $now = Net::AMQP::Value::Timestamp->new(8.2); cmp_ok( $hi, 'eq', 'hi'); cmp_ok( 'x', 'gt', $hi ); cmp_ok( $four, '==', 4 ); cmp_ok( $four, 'eq', '4' ); cmp_ok( $four, '<', 4.1 ); cmp_ok( 4.1, '>', $four ); cmp_ok( $now, '==', 8 ); cmp_ok( $now, 'eq', '8' ); cmp_ok( $now, '<', 8.1 ); cmp_ok( 8.1, '>', $now ); cmp_ok( $four, '<', $now ); for (Net::AMQP::Value::false, Net::AMQP::Value::Boolean->new(0), Net::AMQP::Value::Boolean->new('')) { ok(!$_); cmp_ok($_, 'eq', 'false'); cmp_ok($_, 'lt', 'm'); cmp_ok('m', 'gt', $_); cmp_ok($_, '==', 0); cmp_ok($_, '<', 2); cmp_ok(2, '>', $_); } for (Net::AMQP::Value::true, Net::AMQP::Value::Boolean->new(1), Net::AMQP::Value::Boolean->new(42)) { ok($_); cmp_ok($_, 'eq', 'true'); cmp_ok($_, 'gt', 'm'); cmp_ok('m', 'lt', $_); cmp_ok($_, '==', 1); cmp_ok($_, '>', 0); cmp_ok(0, '<', $_); } done_testing(); Net-AMQP-0.06~dfsg/t/01_basic.t0000444000000000000000000000131412140350635014466 0ustar rootrootuse strict; use warnings; use FindBin; use Test::More; BEGIN { use_ok('Net::AMQP'); } Net::AMQP::Protocol->load_xml_spec($FindBin::Bin . '/../spec/amqp0-8.xml'); my $obj = Net::AMQP::Frame::Method->new( method_frame => Net::AMQP::Protocol::Basic::Publish->new( mandatory => 1, routing_key => 'testing', ), ); isa_ok($obj, 'Net::AMQP::Frame::Method'); isa_ok($obj, 'Net::AMQP::Frame'); can_ok($obj, qw(class_id type_id method_frame)); isa_ok($obj->method_frame, 'Net::AMQP::Protocol::Basic::Publish'); isa_ok($obj->method_frame, 'Net::AMQP::Protocol::Base'); can_ok($obj->method_frame, qw(class_id method_id method_spec frame_arguments mandatory routing_key ticket)); done_testing(); Net-AMQP-0.06~dfsg/t/50_autodocs.t0000444000000000000000000000101312140350635015226 0ustar rootrootuse strict; use warnings; use FindBin; use Test::More; BEGIN { use_ok('Net::AMQP'); } Net::AMQP::Protocol->load_xml_spec($FindBin::Bin . '/../spec/amqp0-8.xml'); SKIP: { eval { require File::Temp }; skip "File::Temp is not installed", 1 if $@; my $dir = File::Temp->newdir(); my $dirname = $dir->dirname; Net::AMQP::Protocol->full_docs_to_dir($dirname); #print "Written to $dirname\n"; #system "pod2man $dirname/Net::AMQP::Protocol::Basic::Publish.pod | man -l -"; } done_testing(); Net-AMQP-0.06~dfsg/t/02_ruby_protocol_doc.t0000444000000000000000000003304512140350635017143 0ustar rootrootuse strict; use warnings; use FindBin; use Test::More tests => 23; use Test::Deep; =head1 DESCRIPTION The Ruby AMQP implementation has a good reference document at: http://github.com/tmm1/amqp/raw/4d215f40747bb884e67aada45a33363ae1e62ec1/protocol/doc.txt which carefully documents every send and receive of data, both raw and OO objects, between a basic client and the server. Using Parse::RecDescent, we parse this back and forth log, convert Ruby dumped objects to Perl objects, convert Ruby-escaped raw dumps to binary strings, and then see if we would have done the same thing. =cut BEGIN { use_ok('Net::AMQP'); } Net::AMQP::Protocol->load_xml_spec($FindBin::Bin . '/../spec/amqp0-8.xml'); SKIP: { eval { require Parse::RecDescent }; skip "Parse::RecDescent not installed", 22 if $@; my $debug = 0; my $parser = Parse::RecDescent->new(<<"EOF") or die "Invalid grammar!"; document: dump(s) dump: '[' string ',' (object | string) ']' { print join(',', map { '"' . \$_ . '"' } \@item) . "\\n" if \$::debug; \$return = [ \$item[2] => \$item[4] ]; } string: '"' /[^"]*/ '"' { print "string: '\$item[2]'\\n" if \$::debug; \$return = \$item[2]; } object: '#<' /[A-Za-z0-9:]+/ pair(s /,/) '>' { print "object\\n" if \$::debug; \$return = { id => \$item[2], value => { map { \@\$_ } \@{ \$item[3] } }, }; } pair: "\\\@" /[A-Za-z0-9_]+/ '=' (object | string | /[0-9A-Za-z:]+/ | properties) { print "pair \$item[2] => \$item[4]\\n" if \$::debug; \$return = [ \$item[2] => \$item[4] ]; } properties: '{' prop_pair(s /,/) '}' { print "properties\\n" if \$::debug; \$return = { map { \@\$_ } \@{ \$item[2] } }; } prop_pair: ':' /[A-Za-z0-9_]+/ '=>' (string | /[0-9A-Za-z]+/) { print "prop pair \$item[2] => \$item[4]\\n" if \$::debug; \$return = [ \$item[2] => \$item[4] ]; } EOF local $/ = undef; my $data = ; my $actions = $parser->document($data) or die "Bad input"; my (@receive_frames, @send_data); foreach my $action (@$actions) { my ($type, $data) = @$action; if ($type eq 'receive_data' || $type eq 'send_data') { # Unescape the raw dump $data =~ s{\\(\d\d\d)}{chr(oct $1)}eg; $data =~ s{(\\[a-z])}{$1 eq '\\v' ? chr(11) : eval '"' . $1 . '"'}eg; if ($type eq 'receive_data') { my @frames = Net::AMQP->parse_raw_frames(\$data); push @receive_frames, @frames; } else { my $sent_frame = shift @send_data; if ($sent_frame->type_string eq 'Method Connection.StartOk') { # Special exception for StartOk: the 'client_properties' and 'response' hashes are # serialized in ('information', 'version', 'product', 'platform') and ('LOGIN', 'PASSWORD') # key/value order. This is arbitrary, and we can't compare data->raw with raw in this # case without data->parsed->raw, as we sort the keys before output for doing this comparison. my @frames = Net::AMQP->parse_raw_frames(\$data); is($sent_frame->to_raw_frame, $frames[0]->to_raw_frame, "Sent frame ".$sent_frame->type_string." serialized properlly"); } else { is($sent_frame->to_raw_frame, $data, "Sent frame ".$sent_frame->type_string." serialized properlly"); } } } else { my $object = parse_ruby_dumper_object($data); if ($type eq 'receive') { my $expected_frame = shift @receive_frames; cmp_deeply($object, $expected_frame, "Received frame ".$expected_frame->type_string." deserialized properlly"); } else { push @send_data, $object; } } } } sub parse_ruby_dumper_object { my $data = shift; # Find a perl class name my ($ruby_class, $memory_location) = $data->{id} =~ m{^(.+):([^:]+)$}; my $perl_class = 'Net::' . $ruby_class; my %self = ( %{ $data->{value} }, ($perl_class =~ /Frame/ ? ( type_id => $perl_class->type_id, ) : ()), ); delete $self{debug}; # ruby only while (my ($key, $value) = each %self) { next unless defined $value; $self{$key} = $value eq 'false' ? 0 : $value eq 'true' ? 1 : $value; $self{$key} = undef if $value eq 'nil'; } if ($perl_class eq 'Net::AMQP::Protocol::Header' && $self{klass}) { my $klass = delete $self{klass}; $perl_class = 'Net::' . $klass . '::ContentHeader'; } if (my $payload = delete $self{payload}) { if ($perl_class eq 'Net::AMQP::Frame::Header') { # Ruby AMQP represents their header frames differently then we do my $header_frame = parse_ruby_dumper_object($payload); # 'properties' contains all the wrapped ContentHeader fields my $properties = delete $header_frame->{properties}; $header_frame->{$_} = $properties->{$_} foreach keys %$properties; # Other fields belong in the Frame::Header object $self{body_size} = delete $header_frame->{size}; $self{weight} = delete $header_frame->{weight}; $self{class_id} = $header_frame->class_id; $self{header_frame} = $header_frame; $self{payload} = ''; } elsif ($perl_class eq 'Net::AMQP::Frame::Method') { $self{method_frame} = parse_ruby_dumper_object($payload); $self{payload} = ''; } elsif ($perl_class eq 'Net::AMQP::Frame::Body') { $self{payload} = $payload; } else { die "Invalid class '$perl_class' for payload"; } } return bless \%self, $perl_class; } __DATA__ ["receive_data", "\001\000\000\000\000\001&\000\n\000\n\b\000\000\000\001\001\aproductS\000\000\000\bRabbitMQ\aversionS\000\000\000\v%%VERSION%%\bplatformS\000\000\000\nErlang/OTP\tcopyrightS\000\000\000gCopyright (C) 2007-2008 LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd.\vinformationS\000\000\0005Licensed under the MPL. See http://www.rabbitmq.com/\000\000\000\016PLAIN AMQPLAIN\000\000\000\005en_US\316"] ["receive", #"Licensed under the MPL. See http://www.rabbitmq.com/", :copyright=> "Copyright (C) 2007-2008 LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd.", :platform=>"Erlang/OTP", :version=>"%%VERSION%%", :product=>"RabbitMQ"}, @version_major=8, @version_minor=0>>] ["send", #"http://github.com/tmm1/amqp", :version=>"0.1.0", :product=>"AMQP", :platform=>"Ruby/EventMachine"}, @debug=1, @locale="en_US", @mechanism="AMQPLAIN", @response={:LOGIN=>"guest", :PASSWORD=>"guest"}>>] ["send_data", "\001\000\000\000\000\000\254\000\n\000\v\000\000\000n\vinformationS\000\000\000\ehttp://github.com/tmm1/amqp\aversionS\000\000\000\0050.1.0\aproductS\000\000\000\004AMQP\bplatformS\000\000\000\021Ruby/EventMachine\bAMQPLAIN\000\000\000#\005LOGINS\000\000\000\005guest\bPASSWORDS\000\000\000\005guest\005en_US\316"] ["receive_data", "\001\000\000\000\000\000\f\000\n\000\036\000\000\000\002\000\000\000\000\316"] ["receive", #>] ["send", #>] ["send_data", "\001\000\000\000\000\000\f\000\n\000\037\000\000\000\002\000\000\000\000\316"] ["send", #>] ["send_data", "\001\000\000\000\000\000\b\000\n\000(\001/\000\000\316"] ["receive_data", "\001\000\000\000\000\000\025\000\n\000)\020julie.local:5672\316"] ["receive", #>] ["send", #>] ["send_data", "\001\000\001\000\000\000\005\000\024\000\n\000\316"] ["receive_data", "\001\000\001\000\000\000\004\000\024\000\v\316"] ["receive", #>] ["send", #>] ["send_data", "\001\000\001\000\000\000\v\000\036\000\n\005/data\034\316"] ["receive_data", "\001\000\001\000\000\000\006\000\036\000\v\000e\316"] ["receive", #>] ["send", #>] ["send_data", "\001\000\001\000\000\000\f\0002\000\n\000e\000\b\000\000\000\000\316"] ["receive_data", "\001\000\001\000\000\000-\0002\000\v amq.gen-RCSkW3cCvMc1I0wXBcLYSg==\000\000\000\000\000\000\000\000\316"] ["receive", #>] ["send", #>] ["send_data", "\001\000\001\000\000\0008\0002\000\024\000e amq.gen-RCSkW3cCvMc1I0wXBcLYSg==\000\ntest_route\000\000\000\000\000\316"] ["receive_data", "\001\000\001\000\000\000\004\0002\000\025\316"] ["receive", #>] ["send", #>] ["send_data", "\001\000\001\000\000\000)\000<\000\024\000e amq.gen-RCSkW3cCvMc1I0wXBcLYSg==\000\002\316"] ["receive_data", "\001\000\001\000\000\000&\000<\000\025!amq.ctag-wFbDeuYKGEm7tXh8oaE5Qg==\316"] ["receive", #>] ["send", #>] ["send_data", "\001\000\001\000\000\000\023\000<\000(\000e\000\ntest_route\000\316"] ["send", #1, :priority=>1, :content_type=>"application/octet-stream"}, @size=15, @weight=0>>] ["send_data", "\002\000\001\000\000\000)\000<\000\000\000\000\000\000\000\000\000\017\230\000\030application/octet-stream\001\001\316"] ["send", #] ["send_data", "\003\000\001\000\000\000\017this is a test!\316"] ["receive_data", "\001\000\001\000\000\000;\000<\000>] ["receive", #1, :priority=>1, :content_type=>"application/octet-stream"}, @size=15, @weight=0>>] ["receive", #] Net-AMQP-0.06~dfsg/t/03_standalone_0_8.t0000444000000000000000000003302112140350635016205 0ustar rootrootuse strict; use warnings; use FindBin; use Test::More tests => 24; use Test::Deep; =head1 DESCRIPTION The Ruby AMQP implementation has a good reference document at: http://github.com/tmm1/amqp/raw/4d215f40747bb884e67aada45a33363ae1e62ec1/protocol/doc.txt which carefully documents every send and receive of data, both raw and OO objects, between a basic client and the server. Using Parse::RecDescent, we parse this back and forth log, convert Ruby dumped objects to Perl objects, convert Ruby-escaped raw dumps to binary strings, and then see if we would have done the same thing. =cut BEGIN { use_ok('Net::AMQP::Protocol::v0_8'); use_ok('Net::AMQP::Protocol::v0_8'); } SKIP: { eval { require Parse::RecDescent }; skip "Parse::RecDescent not installed", 22 if $@; my $debug = 0; my $parser = Parse::RecDescent->new(<<"EOF") or die "Invalid grammar!"; document: dump(s) dump: '[' string ',' (object | string) ']' { print join(',', map { '"' . \$_ . '"' } \@item) . "\\n" if \$::debug; \$return = [ \$item[2] => \$item[4] ]; } string: '"' /[^"]*/ '"' { print "string: '\$item[2]'\\n" if \$::debug; \$return = \$item[2]; } object: '#<' /[A-Za-z0-9:]+/ pair(s /,/) '>' { print "object\\n" if \$::debug; \$return = { id => \$item[2], value => { map { \@\$_ } \@{ \$item[3] } }, }; } pair: "\\\@" /[A-Za-z0-9_]+/ '=' (object | string | /[0-9A-Za-z:]+/ | properties) { print "pair \$item[2] => \$item[4]\\n" if \$::debug; \$return = [ \$item[2] => \$item[4] ]; } properties: '{' prop_pair(s /,/) '}' { print "properties\\n" if \$::debug; \$return = { map { \@\$_ } \@{ \$item[2] } }; } prop_pair: ':' /[A-Za-z0-9_]+/ '=>' (string | /[0-9A-Za-z]+/) { print "prop pair \$item[2] => \$item[4]\\n" if \$::debug; \$return = [ \$item[2] => \$item[4] ]; } EOF local $/ = undef; my $data = ; my $actions = $parser->document($data) or die "Bad input"; my (@receive_frames, @send_data); foreach my $action (@$actions) { my ($type, $data) = @$action; if ($type eq 'receive_data' || $type eq 'send_data') { # Unescape the raw dump $data =~ s{\\(\d\d\d)}{chr(oct $1)}eg; $data =~ s{(\\[a-z])}{$1 eq '\\v' ? chr(11) : eval '"' . $1 . '"'}eg; if ($type eq 'receive_data') { my @frames = Net::AMQP->parse_raw_frames(\$data); push @receive_frames, @frames; } else { my $sent_frame = shift @send_data; if ($sent_frame->type_string eq 'Method Connection.StartOk') { # Special exception for StartOk: the 'client_properties' and 'response' hashes are # serialized in ('information', 'version', 'product', 'platform') and ('LOGIN', 'PASSWORD') # key/value order. This is arbitrary, and we can't compare data->raw with raw in this # case without data->parsed->raw, as we sort the keys before output for doing this comparison. my @frames = Net::AMQP->parse_raw_frames(\$data); is($sent_frame->to_raw_frame, $frames[0]->to_raw_frame, "Sent frame ".$sent_frame->type_string." serialized properlly"); } else { is($sent_frame->to_raw_frame, $data, "Sent frame ".$sent_frame->type_string." serialized properlly"); } } } else { my $object = parse_ruby_dumper_object($data); if ($type eq 'receive') { my $expected_frame = shift @receive_frames; cmp_deeply($object, $expected_frame, "Received frame ".$expected_frame->type_string." deserialized properlly"); } else { push @send_data, $object; } } } } sub parse_ruby_dumper_object { my $data = shift; # Find a perl class name my ($ruby_class, $memory_location) = $data->{id} =~ m{^(.+):([^:]+)$}; my $perl_class = 'Net::' . $ruby_class; my %self = ( %{ $data->{value} }, ($perl_class =~ /Frame/ ? ( type_id => $perl_class->type_id, ) : ()), ); delete $self{debug}; # ruby only while (my ($key, $value) = each %self) { next unless defined $value; $self{$key} = $value eq 'false' ? 0 : $value eq 'true' ? 1 : $value; $self{$key} = undef if $value eq 'nil'; } if ($perl_class eq 'Net::AMQP::Protocol::Header' && $self{klass}) { my $klass = delete $self{klass}; $perl_class = 'Net::' . $klass . '::ContentHeader'; } if (my $payload = delete $self{payload}) { if ($perl_class eq 'Net::AMQP::Frame::Header') { # Ruby AMQP represents their header frames differently then we do my $header_frame = parse_ruby_dumper_object($payload); # 'properties' contains all the wrapped ContentHeader fields my $properties = delete $header_frame->{properties}; $header_frame->{$_} = $properties->{$_} foreach keys %$properties; # Other fields belong in the Frame::Header object $self{body_size} = delete $header_frame->{size}; $self{weight} = delete $header_frame->{weight}; $self{class_id} = $header_frame->class_id; $self{header_frame} = $header_frame; $self{payload} = ''; } elsif ($perl_class eq 'Net::AMQP::Frame::Method') { $self{method_frame} = parse_ruby_dumper_object($payload); $self{payload} = ''; } elsif ($perl_class eq 'Net::AMQP::Frame::Body') { $self{payload} = $payload; } else { die "Invalid class '$perl_class' for payload"; } } return bless \%self, $perl_class; } __DATA__ ["receive_data", "\001\000\000\000\000\001&\000\n\000\n\b\000\000\000\001\001\aproductS\000\000\000\bRabbitMQ\aversionS\000\000\000\v%%VERSION%%\bplatformS\000\000\000\nErlang/OTP\tcopyrightS\000\000\000gCopyright (C) 2007-2008 LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd.\vinformationS\000\000\0005Licensed under the MPL. See http://www.rabbitmq.com/\000\000\000\016PLAIN AMQPLAIN\000\000\000\005en_US\316"] ["receive", #"Licensed under the MPL. See http://www.rabbitmq.com/", :copyright=> "Copyright (C) 2007-2008 LShift Ltd., Cohesive Financial Technologies LLC., and Rabbit Technologies Ltd.", :platform=>"Erlang/OTP", :version=>"%%VERSION%%", :product=>"RabbitMQ"}, @version_major=8, @version_minor=0>>] ["send", #"http://github.com/tmm1/amqp", :version=>"0.1.0", :product=>"AMQP", :platform=>"Ruby/EventMachine"}, @debug=1, @locale="en_US", @mechanism="AMQPLAIN", @response={:LOGIN=>"guest", :PASSWORD=>"guest"}>>] ["send_data", "\001\000\000\000\000\000\254\000\n\000\v\000\000\000n\vinformationS\000\000\000\ehttp://github.com/tmm1/amqp\aversionS\000\000\000\0050.1.0\aproductS\000\000\000\004AMQP\bplatformS\000\000\000\021Ruby/EventMachine\bAMQPLAIN\000\000\000#\005LOGINS\000\000\000\005guest\bPASSWORDS\000\000\000\005guest\005en_US\316"] ["receive_data", "\001\000\000\000\000\000\f\000\n\000\036\000\000\000\002\000\000\000\000\316"] ["receive", #>] ["send", #>] ["send_data", "\001\000\000\000\000\000\f\000\n\000\037\000\000\000\002\000\000\000\000\316"] ["send", #>] ["send_data", "\001\000\000\000\000\000\b\000\n\000(\001/\000\000\316"] ["receive_data", "\001\000\000\000\000\000\025\000\n\000)\020julie.local:5672\316"] ["receive", #>] ["send", #>] ["send_data", "\001\000\001\000\000\000\005\000\024\000\n\000\316"] ["receive_data", "\001\000\001\000\000\000\004\000\024\000\v\316"] ["receive", #>] ["send", #>] ["send_data", "\001\000\001\000\000\000\v\000\036\000\n\005/data\034\316"] ["receive_data", "\001\000\001\000\000\000\006\000\036\000\v\000e\316"] ["receive", #>] ["send", #>] ["send_data", "\001\000\001\000\000\000\f\0002\000\n\000e\000\b\000\000\000\000\316"] ["receive_data", "\001\000\001\000\000\000-\0002\000\v amq.gen-RCSkW3cCvMc1I0wXBcLYSg==\000\000\000\000\000\000\000\000\316"] ["receive", #>] ["send", #>] ["send_data", "\001\000\001\000\000\0008\0002\000\024\000e amq.gen-RCSkW3cCvMc1I0wXBcLYSg==\000\ntest_route\000\000\000\000\000\316"] ["receive_data", "\001\000\001\000\000\000\004\0002\000\025\316"] ["receive", #>] ["send", #>] ["send_data", "\001\000\001\000\000\000)\000<\000\024\000e amq.gen-RCSkW3cCvMc1I0wXBcLYSg==\000\002\316"] ["receive_data", "\001\000\001\000\000\000&\000<\000\025!amq.ctag-wFbDeuYKGEm7tXh8oaE5Qg==\316"] ["receive", #>] ["send", #>] ["send_data", "\001\000\001\000\000\000\023\000<\000(\000e\000\ntest_route\000\316"] ["send", #1, :priority=>1, :content_type=>"application/octet-stream"}, @size=15, @weight=0>>] ["send_data", "\002\000\001\000\000\000)\000<\000\000\000\000\000\000\000\000\000\017\230\000\030application/octet-stream\001\001\316"] ["send", #] ["send_data", "\003\000\001\000\000\000\017this is a test!\316"] ["receive_data", "\001\000\001\000\000\000;\000<\000>] ["receive", #1, :priority=>1, :content_type=>"application/octet-stream"}, @size=15, @weight=0>>] ["receive", #] Net-AMQP-0.06~dfsg/Build.PL0000444000000000000000000000102512140350635013750 0ustar rootrootuse Module::Build; die "Perl 5.6 required" if $] < 5.006; my $build = Module::Build->new( module_name => 'Net::AMQP', license => 'perl', build_requires => { 'File::Temp' => 0.19, 'Test::More' => 0.88, 'Test::Deep' => 0, }, requires => { 'Scalar::Util' => 0, 'Class::Accessor' => 0, 'Class::Data::Inheritable' => 0, 'XML::LibXML' => 0, }, sign => 1, create_makefile_pl => 'passthrough', create_readme => 1, ); $build->create_build_script; Net-AMQP-0.06~dfsg/META.json0000444000000000000000000000546212140350635014106 0ustar rootroot{ "abstract" : "Advanced Message Queue Protocol (de)serialization and representation", "author" : [ "Eric Waters " ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.4004, CPAN::Meta::Converter version 2.130880", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Net-AMQP", "prereqs" : { "build" : { "requires" : { "File::Temp" : "0.19", "Test::Deep" : "0", "Test::More" : "0.88" } }, "configure" : { "requires" : { "Module::Build" : "0.40" } }, "runtime" : { "requires" : { "Class::Accessor" : "0", "Class::Data::Inheritable" : "0", "Scalar::Util" : "0", "XML::LibXML" : "0" } } }, "provides" : { "Net::AMQP" : { "file" : "lib/Net/AMQP.pm", "version" : "0.06" }, "Net::AMQP::Common" : { "file" : "lib/Net/AMQP/Common.pm" }, "Net::AMQP::Frame" : { "file" : "lib/Net/AMQP/Frame.pm" }, "Net::AMQP::Frame::Body" : { "file" : "lib/Net/AMQP/Frame/Body.pm" }, "Net::AMQP::Frame::Header" : { "file" : "lib/Net/AMQP/Frame/Header.pm" }, "Net::AMQP::Frame::Heartbeat" : { "file" : "lib/Net/AMQP/Frame/Heartbeat.pm" }, "Net::AMQP::Frame::Method" : { "file" : "lib/Net/AMQP/Frame/Method.pm" }, "Net::AMQP::Frame::OOBBody" : { "file" : "lib/Net/AMQP/Frame/OOBBody.pm" }, "Net::AMQP::Frame::OOBHeader" : { "file" : "lib/Net/AMQP/Frame/OOBHeader.pm" }, "Net::AMQP::Frame::OOBMethod" : { "file" : "lib/Net/AMQP/Frame/OOBMethod.pm" }, "Net::AMQP::Frame::Trace" : { "file" : "lib/Net/AMQP/Frame/Trace.pm" }, "Net::AMQP::Protocol" : { "file" : "lib/Net/AMQP/Protocol.pm" }, "Net::AMQP::Protocol::Base" : { "file" : "lib/Net/AMQP/Protocol/Base.pm" }, "Net::AMQP::Protocol::v0_8" : { "file" : "lib/Net/AMQP/Protocol/v0_8.pm" }, "Net::AMQP::Value" : { "file" : "lib/Net/AMQP/Value.pm" }, "Net::AMQP::Value::Boolean" : { "file" : "lib/Net/AMQP/Value.pm" }, "Net::AMQP::Value::Integer" : { "file" : "lib/Net/AMQP/Value.pm" }, "Net::AMQP::Value::String" : { "file" : "lib/Net/AMQP/Value.pm" }, "Net::AMQP::Value::Timestamp" : { "file" : "lib/Net/AMQP/Value.pm" } }, "release_status" : "stable", "resources" : { "license" : [ "http://dev.perl.org/licenses/" ] }, "version" : "0.06" } Net-AMQP-0.06~dfsg/CHANGES0000444000000000000000000000361512140350635013456 0ustar rootroot0.06 Wed May 1 19:37:50 PDT 2013 - Require Perl 5.006 to get pack 'q' for quads. C'mon, it's been over a decade now. - Support packing and unpacking of full range of signed and unsigned integer values, though broker differences may make their use problematic. - Fix signedness of integer packing and unpacking (signed were treated as unsigned). - Introduce Net::AMQP::Value::* classes to control packing of table values. - In tables, pack and unpack undefs as void and values from the "boolean" class as bools. - Support decoding the Heartbeat frame type. - Include AMQP 0-9-1 spec. - Document that AMQP 0-9, 0-9-1, and 0-10 specs can be used, though support is not complete. - New co-maintainer Chip Salzenberg. 0.05 Sun Sep 16 12:08:14 EDT 2012 - Pack/unpack 't' field type from Brad Barden - Support AMQP 0-9 from Chip Salzenberg [https://github.com/chipdude] 0.04 Mon, 21 May 2012 12:20:13 -0400 - More performance optimizations from José Micó [https://github.com/ewaters/net-amqp/pull/4] - Pack unit values as unit in tables and arrays from Dan Conlon [https://github.com/ewaters/net-amqp/pull/5] 0.03 Mon, 09 Apr 2012 12:36:02 -0400 - Performance optimizations for frame deserialization [https://github.com/ewaters/net-amqp/pull/3] 0.02 Fri, 11 Nov 2011 07:16:09 -0700 - note File::Temp version requirement [https://github.com/joodie] - additional field 'content' from spec [https://github.com/teftin] - Ignore partial frames until they're complete; inspired by Steve Fink [https://github.com/chipdude] - Support field type "A" - field array [https://github.com/chipdude] 0.01.1 Wed, 05 Aug 2009 09:33:09 -0600 - Fixed typo in t/02_ruby_protocol_doc.t for detecting skip - Added version requirement for Test::More to support done_testing() 0.01 Wed, 15 Jul 2009 14:33:48 -0600 - First working version released to CPAN Net-AMQP-0.06~dfsg/README0000444000000000000000000000605512140350635013344 0ustar rootrootNAME Net::AMQP - Advanced Message Queue Protocol (de)serialization and representation SYNOPSIS use Net::AMQP; Net::AMQP::Protocol->load_xml_spec('amqp0-8.xml'); ... my @frames = Net::AMQP->parse_raw_frames(\$input); ... foreach my $frame (@frames) { if ($frame->can('method_frame') && $frame->method_frame->isa('Net::AMQP::Protocol::Connection::Start')) { my $output = Net::AMQP::Frame::Method->new( channel => 0, method_frame => Net::AMQP::Protocol::Connection::StartOk->new( client_properties => { ... }, mechanism => 'AMQPLAIN', locale => 'en_US', response => { LOGIN => 'guest', PASSWORD => 'guest', }, ), ); print OUT $output->to_raw_frame(); } } DESCRIPTION This module implements the frame (de)serialization and representation of the Advanced Message Queue Protocol (http://www.amqp.org/). It is to be used in conjunction with client or server software that does the actual TCP/IP communication. CLASS METHODS parse_raw_frames Net::AMQP->parse_raw_frames(\$binary_payload) Given a scalar reference to a binary string, return a list of Net::AMQP::Frame objects, consuming the data in the string. Croaks on invalid input. SEE ALSO Net::AMQP::Value, Net::RabbitMQ, AnyEvent::RabbitMQ, Net::RabbitFoot, POE::Component::Client::AMQP AMQP VERSIONS AMQP 0-8 is fully supported. AMQP 0-9, 0-9-1, and 0-10 are usably supported. There are interoperability issues with table encodings because the standard disagrees with the dialects of major implementations (RabbitMQ and Qpid). For now, Net::AMQP limits itself to universally agreed table elements. See for details. AMQP 1.0 has not been tested. TODO Address the dialect problem, either via modified spec files that completely control the wire protocol, or by programmatic request. The former has precedent (viz "qpid.amqp0-8.xml" in spec), but could cause a combinatorial explosion as more brokers and versions are added. The latter adds interface complexity. QUOTES "All problems in computer science can be solved by another level of indirection." -- David Wheeler's observation "...except for the problem of too many layers of indirection." -- Kevlin Henney's corollary COPYRIGHT Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). Copyright (c) 2012, 2013 Chip Salzenberg and Topsy Labs (http://labs.topsy.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. AUTHOR Eric Waters Net-AMQP-0.06~dfsg/LICENSE0000444000000000000000000005010112140350635013460 0ustar rootrootTerms of Perl itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --------------------------------------------------------------------------- The General Public License (GPL) Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS --------------------------------------------------------------------------- The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. Aggregation of this Package with a commercial distribution is always permitted provided that the use of this Package is embedded; that is, when no overt attempt is made to make this Package's interfaces visible to the end user of the commercial distribution. Such use shall not be construed as a distribution of this Package. 9. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Net-AMQP-0.06~dfsg/lib/0000755000000000000000000000000012140350635013226 5ustar rootrootNet-AMQP-0.06~dfsg/lib/Net/0000755000000000000000000000000012140350635013754 5ustar rootrootNet-AMQP-0.06~dfsg/lib/Net/AMQP/0000755000000000000000000000000012140350635014512 5ustar rootrootNet-AMQP-0.06~dfsg/lib/Net/AMQP/Frame/0000755000000000000000000000000012140350635015544 5ustar rootrootNet-AMQP-0.06~dfsg/lib/Net/AMQP/Frame/OOBHeader.pm0000444000000000000000000000131112140350635017624 0ustar rootrootpackage Net::AMQP::Frame::OOBHeader; =head1 NAME Net::AMQP::Frame::OOBHeader - AMQP wire-level out-of-band header Frame object =head1 DESCRIPTION Inherits from L. =cut use strict; use warnings; use base qw(Net::AMQP::Frame::Header); __PACKAGE__->type_id(5); =head1 SEE ALSO L =head1 COPYRIGHT Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. =head1 AUTHOR Eric Waters =cut 1; Net-AMQP-0.06~dfsg/lib/Net/AMQP/Frame/OOBBody.pm0000444000000000000000000000127512140350635017342 0ustar rootrootpackage Net::AMQP::Frame::OOBBody; =head1 NAME Net::AMQP::Frame::OOBBody - AMQP wire-level out-of-band body Frame object =head1 DESCRIPTION Inherits from L. =cut use strict; use warnings; use base qw(Net::AMQP::Frame::Body); __PACKAGE__->type_id(6); =head1 SEE ALSO L =head1 COPYRIGHT Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. =head1 AUTHOR Eric Waters =cut 1; Net-AMQP-0.06~dfsg/lib/Net/AMQP/Frame/OOBMethod.pm0000444000000000000000000000131112140350635017654 0ustar rootrootpackage Net::AMQP::Frame::OOBMethod; =head1 NAME Net::AMQP::Frame::OOBMethod - AMQP wire-level out-of-band method Frame object =head1 DESCRIPTION Inherits from L. =cut use strict; use warnings; use base qw(Net::AMQP::Frame::Method); __PACKAGE__->type_id(4); =head1 SEE ALSO L =head1 COPYRIGHT Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. =head1 AUTHOR Eric Waters =cut 1; Net-AMQP-0.06~dfsg/lib/Net/AMQP/Frame/Trace.pm0000444000000000000000000000123512140350635017137 0ustar rootrootpackage Net::AMQP::Frame::Trace; =head1 NAME Net::AMQP::Frame::Trace - AMQP wire-level trace Frame object =head1 DESCRIPTION Inherits from L. =cut use strict; use warnings; use base qw(Net::AMQP::Frame); __PACKAGE__->type_id(7); =head1 SEE ALSO L =head1 COPYRIGHT Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. =head1 AUTHOR Eric Waters =cut 1; Net-AMQP-0.06~dfsg/lib/Net/AMQP/Frame/Body.pm0000444000000000000000000000147612140350635017005 0ustar rootrootpackage Net::AMQP::Frame::Body; =head1 NAME Net::AMQP::Frame::Body - AMQP wire-level body Frame object =head1 DESCRIPTION Inherits from L. =cut use strict; use warnings; use base qw(Net::AMQP::Frame); __PACKAGE__->type_id(3); sub parse_payload { my $self = shift; # Nothing to be done; it's already there } sub to_raw_payload { my $self = shift; return $self->payload; } =head1 SEE ALSO L =head1 COPYRIGHT Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. =head1 AUTHOR Eric Waters =cut 1; Net-AMQP-0.06~dfsg/lib/Net/AMQP/Frame/Method.pm0000444000000000000000000001254512140350635017327 0ustar rootrootpackage Net::AMQP::Frame::Method; =head1 NAME Net::AMQP::Frame::Method - AMQP wire-level method Frame object =head1 DESCRIPTION Inherits from L. =cut use strict; use warnings; use base qw(Net::AMQP::Frame); use Net::AMQP::Common qw(:all); use Carp; BEGIN { __PACKAGE__->mk_accessors(qw( class_id method_id method_frame )); } __PACKAGE__->type_id(1); =head1 OBJECT METHODS =over 4 Provides the following field accessors =over 4 =item I =item I =item I Exposes the L object that this frame wraps =back =back =cut my $Registered_method_classes = {}; sub register_method_class { my ($self_class, $method_class) = @_; my ($class_id, $method_id) = ($method_class->class_id, $method_class->method_id); my $key = join ':', $class_id, $method_id; if (exists $Registered_method_classes->{$key}) { my $exists = $Registered_method_classes->{$key}->{class}; croak "Can't register method class for $key: already used by '$exists'"; } my $arguments = $method_class->frame_arguments; my (@frame_args, @pack_args, @unpack_args); for (my $i = 0; $i < @$arguments; $i += 2) { my ($key, $type) = ($arguments->[$i], $arguments->[$i + 1]); no strict 'refs'; push @frame_args, $key; push @pack_args, ($type eq 'bit') ? 'bit' : *{'Net::AMQP::Common::pack_' . $type}; push @unpack_args, ($type eq 'bit') ? 'bit' : *{'Net::AMQP::Common::unpack_' . $type}; } $Registered_method_classes->{$key} = { class => $method_class, frame_args => \@frame_args, pack_args => \@pack_args, unpack_args => \@unpack_args, }; } sub parse_payload { my $self = shift; my $payload_ref = \$$self{payload}; my ($class_id, $method_id) = unpack 'nn', substr $$payload_ref, 0, 4, ''; my $key = join ':', $class_id, $method_id; my $registered = $Registered_method_classes->{$key} or croak "Failed to find a method class to handle $key"; my $method_class = $registered->{class}; my $arguments = $registered->{frame_args}; my $unpack_args = $registered->{unpack_args}; my %method_frame; for (my $i = 0; $i < @$arguments; $i++) { if ($unpack_args->[$i] eq 'bit') { # Unpack next octet my @bits = split '', unpack("b8", substr($$payload_ref, 0, 1, '')); while (1) { $method_frame{$arguments->[$i]} = shift @bits; # Group all following bits together into octets, up to 8 last unless ($i+1 < @$arguments && $unpack_args->[$i+1] eq 'bit'); last unless @bits; $i++; } next; } # $unpack_args->[$i] is a coderef of Net::AMQP::Common::unpack_$type my $value = $unpack_args->[$i]->( $payload_ref ); if (! defined $value) { my ($key, $unpacker) = ($arguments->[$i], $unpack_args->[$i]); die "Failed to unpack key '$key' with $unpacker for frame of type '$method_class' from input '$$payload_ref'"; } $method_frame{$arguments->[$i]} = $value; } $self->method_frame($method_class->new(%method_frame)); } sub to_raw_payload { my $self = shift; my $method_frame = $self->method_frame; my $class_id = $self->class_id; my $method_id = $self->method_id; $class_id = $self->class_id( $method_frame->class_id ) unless defined $class_id; $method_id = $self->method_id( $method_frame->method_id ) unless defined $method_id; my $response_payload = ''; $response_payload .= pack_short_integer($class_id); $response_payload .= pack_short_integer($method_id); my $key = join ':', $class_id, $method_id; my $registered = $Registered_method_classes->{$key}; my $arguments = $registered->{frame_args}; my $pack_args = $registered->{pack_args}; for (my $i = 0; $i < @$arguments; $i++) { if ($pack_args->[$i] eq 'bit') { my $bits = ''; while (1) { $bits .= $method_frame->{$arguments->[$i]} ? '1' : '0'; # Group all following bits together into octets, up to 8 last unless ($i+1 < @$arguments && $pack_args->[$i+1] eq 'bit'); last unless (length $bits < 8); $i++; } $response_payload .= pack("b8", $bits); next; } # $pack_args->[$i] is a coderef of Net::AMQP::Common::pack_$type my $value = $pack_args->[$i]->( $method_frame->{$arguments->[$i]} ); if (! defined $value) { my ($key, $packer) = ($arguments->[$i], $pack_args->[$i]); die "Failed to pack key '$key' with $packer for frame of type '".ref($method_frame)."' from input '$$method_frame{$key}'"; } $response_payload .= $value; } return $response_payload; } =head1 SEE ALSO L =head1 COPYRIGHT Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. =head1 AUTHOR Eric Waters =cut 1; Net-AMQP-0.06~dfsg/lib/Net/AMQP/Frame/Header.pm0000444000000000000000000001223012140350635017266 0ustar rootrootpackage Net::AMQP::Frame::Header; =head1 NAME Net::AMQP::Frame::Header - AMQP wire-level header Frame object =head1 DESCRIPTION Inherits from L. =cut use strict; use warnings; use base qw(Net::AMQP::Frame); use Net::AMQP::Common qw(:all); use Carp qw(croak cluck); BEGIN { __PACKAGE__->mk_accessors(qw( class_id weight body_size header_frame )); } __PACKAGE__->type_id(2); =head1 OBJECT METHODS Provides the following field accessors =over 4 =item I =item I =item I =item I Exposes the L object that this frame wraps =back =cut my $Registered_header_classes = {}; sub register_header_class { my ($self_class, $header_class) = @_; my $class_id = $header_class->class_id; if (exists $Registered_header_classes->{$class_id}) { my $exists = $Registered_header_classes->{$class_id}->{class}; croak "Can't register header class for $class_id: already used by '$exists'"; } my $arguments = $header_class->frame_arguments; my (@frame_args, @pack_args, @unpack_args); for (my $i = 0; $i < @$arguments; $i += 2) { my ($key, $type) = ($arguments->[$i], $arguments->[$i + 1]); no strict 'refs'; push @frame_args, $key; push @pack_args, ($type eq 'bit') ? 'bit' : *{'Net::AMQP::Common::pack_' . $type}; push @unpack_args, ($type eq 'bit') ? 'bit' : *{'Net::AMQP::Common::unpack_' . $type}; } $Registered_header_classes->{$class_id} = { class => $header_class, frame_args => \@frame_args, pack_args => \@pack_args, unpack_args => \@unpack_args, }; } sub parse_payload { my $self = shift; my $payload_ref = \$$self{payload}; $self->class_id( unpack_short_integer($payload_ref) ); $self->weight( unpack_short_integer($payload_ref) ); $self->body_size( unpack_long_long_integer($payload_ref) ); my $registered = $Registered_header_classes->{ $self->class_id } or croak "Failed to find a header class to handle ".$self->class_id; my $header_class = $registered->{class}; my $arguments = $registered->{frame_args}; my $unpack_args = $registered->{unpack_args}; my %header_frame; my @fields_set; while (1) { # Unpack property flags push @fields_set, split '', unpack("B16", substr($$payload_ref, 0, 2, '')); # If bit 0 is true, there are more bytes to unpack last unless (pop @fields_set); } for (my $i = 0; $i < @$arguments; $i++) { next unless ($fields_set[$i]); # $unpack_args->[$i] is a coderef of Net::AMQP::Common::unpack_$type my $value = $unpack_args->[$i]->( $payload_ref ); if (! defined $value) { my ($key, $unpacker) = ($arguments->[$i], $unpack_args->[$i]); die "Failed to unpack key '$key' with $unpacker for frame of type '$header_class' from input '$$payload_ref'"; } $header_frame{$arguments->[$i]} = $value; } $self->header_frame($header_class->new(%header_frame)); } sub to_raw_payload { my $self = shift; my $header_frame = $self->header_frame; my $class_id = $self->class_id; $class_id = $self->class_id( $header_frame->class_id ) unless defined $class_id; my $response_payload = ''; $response_payload .= pack_short_integer($class_id); $response_payload .= pack_short_integer($self->weight); $response_payload .= pack_long_long_integer($self->body_size); my $registered = $Registered_header_classes->{$class_id}; my $arguments = $registered->{frame_args}; my $pack_args = $registered->{pack_args}; my $raw_values = ''; my $fields_set = ''; for (my $i = 0; $i < @$arguments; $i++) { if (! defined $header_frame->{$arguments->[$i]}) { $fields_set .= '0'; next; } else { $fields_set .= '1'; } # $pack_args->[$i] is a coderef of Net::AMQP::Common::pack_$type my $value = $pack_args->[$i]->( $header_frame->{$arguments->[$i]} ); if (! defined $value) { my ($key, $packer) = ($arguments->[$i], $pack_args->[$i]); die "Failed to pack key '$key' with $packer for frame of type '".ref($header_frame)."' from input '$$header_frame{$key}'"; } $raw_values .= $value; } while (length $fields_set) { # Pack property flags my $flags = substr($fields_set, 0, 15, ''); $flags .= '0' x (15 - length $flags); # Set bit 0 if there are more bits to pack $flags .= (length $fields_set) ? '1' : '0'; $response_payload .= pack("B16", $flags); } $response_payload .= $raw_values; return $response_payload; } =head1 SEE ALSO L =head1 COPYRIGHT Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. =head1 AUTHOR Eric Waters =cut 1; Net-AMQP-0.06~dfsg/lib/Net/AMQP/Frame/Heartbeat.pm0000444000000000000000000000142412140350635020000 0ustar rootrootpackage Net::AMQP::Frame::Heartbeat; =head1 NAME Net::AMQP::Frame::Heartbeat - AMQP wire-level heartbeat Frame object =head1 DESCRIPTION Inherits from L. =cut use strict; use warnings; use base qw(Net::AMQP::Frame); __PACKAGE__->type_id(8); sub parse_payload { my $self = shift; } sub to_raw_payload { my $self = shift; return ''; } =head1 SEE ALSO L =head1 COPYRIGHT Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. =head1 AUTHOR Eric Waters =cut 1; Net-AMQP-0.06~dfsg/lib/Net/AMQP/Value.pm0000444000000000000000000000466212140350635016132 0ustar rootroot=head1 NAME Net::AMQP::Value - A collection of classes for typing AMQP data =head1 SYNOPSIS use Net::AMQP::Value; # ... somewhere, in an AMQP table: Net::AMQP::Value::String->new("1") # not an integer Net::AMQP::Value::Integer->new(" 1") # not a string Net::AMQP::Value::Timestamp->new(1) # not an integer Net::AMQP::Value::Boolean->new(1) # not an integer Net::AMQP::Value::true # shorthand for ...Boolean->new(1) Net::AMQP::Value::false # shorthand for ...Boolean->new(0) =head1 DESCRIPTION Generally in tables Net::AMQP tries to be smart, so e.g. a table value of '1' or '-1' is transmitted as an integer. When this intelligence becomes a problem, use these classes to type your data. For example, a table value of Cnew(1)> will be transmitted as the string "1". These classes also overload the basics like "", 0+, and bool so if you use them outside an AMQP table, they will probably Do The Right Thing. =head1 SEE ALSO L, L =cut use strict; use Net::AMQP::Common (); package Net::AMQP::Value; use overload '""' => sub { shift->[0] }, 'cmp' => sub { ($_[0][0] cmp $_[1]) * ($_[2] ? -1 : 1) }, '<=>' => sub { ($_[0][0] <=> $_[1]) * ($_[2] ? -1 : 1) }; sub new { bless [ $_[1] ], $_[0] } package Net::AMQP::Value::String; use base qw( Net::AMQP::Value ); sub field_packed { 'S' . Net::AMQP::Common::pack_long_string(shift->[0]) } package Net::AMQP::Value::Integer; use base qw( Net::AMQP::Value ); use overload '0+' => sub { shift->[0] }; sub new { bless [ defined($_[1]) ? int($_[1]) : 0 ], $_[0] } sub field_packed { 'I' . Net::AMQP::Common::pack_long_integer(shift->[0]) } package Net::AMQP::Value::Timestamp; use base qw( Net::AMQP::Value::Integer ); # unsigned, but ok sub field_packed { 'T' . Net::AMQP::Common::pack_timestamp(shift->[0]) } package Net::AMQP::Value::Boolean; use base qw( Net::AMQP::Value ); sub _num { shift->[0] } sub _str { shift->[0] ? 'true' : 'false' }; use overload bool => \&_num, '0+' => \&_num, '""' => \&_str, 'cmp' => sub { (_str($_[0]) cmp $_[1]) * ($_[2] ? -1 : 1) }; sub new { bless [ $_[1] ? 1 : 0 ], $_[0] } sub field_packed { 't' . Net::AMQP::Common::pack_boolean(shift->[0]) } package Net::AMQP::Value; use constant { false => Net::AMQP::Value::Boolean->new(0), true => Net::AMQP::Value::Boolean->new(1), }; 1; Net-AMQP-0.06~dfsg/lib/Net/AMQP/Protocol/0000755000000000000000000000000012172762655016331 5ustar rootrootNet-AMQP-0.06~dfsg/lib/Net/AMQP/Protocol/Base.pm0000444000000000000000000001256412140350635017531 0ustar rootrootpackage Net::AMQP::Protocol::Base; =head1 NAME Net::AMQP::Protocol::Base - Base class of auto-generated protocol classes =head1 DESCRIPTION See L for how subclasses to this class are auto-generated. =cut use strict; use warnings; use base qw(Class::Data::Inheritable Class::Accessor::Fast); BEGIN { __PACKAGE__->mk_classdata($_) foreach qw( class_id method_id frame_arguments class_spec method_spec ); } =head1 CLASS METHODS =head2 class_id The class id from the specficiation. =head2 method_id The method id from the specification. In the case of a content (such as Basic, File or Stream), method_id is 0 for the virtual ContentHeader method. This allows you to create a Header frame in much the same way you create a Method frame, but with the virtual method 'ContentHeader'. For example: my $header_frame = Net::AMQP::Protocol::Basic::ContentHeader->new( content_type => 'text/html' ); print $header_frame->method_id(); # prints '0' =head2 frame_arguments Contains an ordered arrayref of the fields that comprise a frame for this method. For example: Net::AMQP::Protocol::Channel::Open->frame_arguments([ out_of_band => 'short_string' ]); This is used by the L subclasses to (de)serialize raw binary data. Each of these fields are also an accessor for the class objects. =head2 class_spec Contains the hashref that the C call generated for this class. =head2 method_spec Same as above, but for this method. =back =cut sub new { my ($class, %self) = @_; return bless \%self, $class; } sub register { my $class = shift; # Inform the Frame::Method class of the existance of this method type if ($class->class_id && $class->method_id) { Net::AMQP::Frame::Method->register_method_class($class); } elsif ($class->class_id && ! $class->method_id) { Net::AMQP::Frame::Header->register_header_class($class); } # Create accessor methods in the subclass for frame data my @accessors; my $arguments = $class->frame_arguments; for (my $i = 0; $i <= $#{ $arguments }; $i += 2) { my ($key, $type) = ($arguments->[$i], $arguments->[$i + 1]); push @accessors, $key; } $class->mk_accessors(@accessors); } =head1 OBJECT METHODS =head2 frame_wrap Returns a L subclass object that wraps the given object, if possible. =cut sub frame_wrap { my $self = shift; if ($self->class_id && $self->method_id) { return Net::AMQP::Frame::Method->new( method_frame => $self ); } elsif ($self->class_id) { return Net::AMQP::Frame::Header->new( header_frame => $self ); } else { return $self; } } sub docs_as_pod { my $class = shift; my $package = __PACKAGE__; my $class_spec = $class->class_spec; my $method_spec = $class->method_spec; my $frame_arguments = $class->frame_arguments; my $description = "This is an auto-generated subclass of L<$package>; see the docs for that module for inherited methods. Check the L below for details on the auto-generated methods within this class.\n"; if ($class->method_id == 0) { my $base_class = 'Net::AMQP::Protocol::' . $class_spec->{name}; $description .= "\n" . < objects for L<$base_class> frames. EOF } else { $description .= "\n" . "This class implements the class B<$$class_spec{name}> (id ".$class->class_id.") method B<$$method_spec{name}> (id ".$class->method_id."), which is ".($method_spec->{synchronous} ? 'a synchronous' : 'an asynchronous')." method\n"; } my $synopsis_new_args = ''; my $usage = < and are also read/write accessors. =over EOF use Data::Dumper; #$usage .= Dumper($method_spec); foreach my $field_spec (@{ $method_spec->{fields} }) { my $type = $field_spec->{type}; # may be 'undef' if ($field_spec->{domain}) { $type = $Net::AMQP::Protocol::spec{domain}{ $field_spec->{domain} }{type}; } my $local_name = $field_spec->{name}; $local_name =~ s{ }{_}g; $field_spec->{doc} ||= ''; $usage .= < (type: $type) $$field_spec{doc} EOF $synopsis_new_args .= < \$$local_name, EOF } chomp $synopsis_new_args; # trailing \n $usage .= "=back\n\n"; my $pod = <new( $synopsis_new_args ); =head1 DESCRIPTION $description =head1 USAGE $usage =head1 SEE ALSO L<$package> EOF $pod =~ s{^ =}{=}gms; return $pod; } =head1 SEE ALSO L =head1 COPYRIGHT Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. =head1 AUTHOR Eric Waters =cut 1; Net-AMQP-0.06~dfsg/lib/Net/AMQP/Frame.pm0000444000000000000000000000756612140350635016116 0ustar rootrootpackage Net::AMQP::Frame; =head1 NAME Net::AMQP::Frame - AMQP wire-level Frame object =cut use strict; use warnings; use base qw(Class::Data::Inheritable Class::Accessor::Fast); use Net::AMQP::Common qw(:all); use Carp; BEGIN { __PACKAGE__->mk_classdata('type_id'); __PACKAGE__->mk_accessors(qw( channel size payload )); } # Use all the subclasses use Net::AMQP::Frame::Method; use Net::AMQP::Frame::Header; use Net::AMQP::Frame::Body; use Net::AMQP::Frame::OOBMethod; use Net::AMQP::Frame::OOBHeader; use Net::AMQP::Frame::OOBBody; use Net::AMQP::Frame::Trace; use Net::AMQP::Frame::Heartbeat; =head1 CLASS METHODS =head2 new Takes an arbitrary list of key/value pairs and casts it into this class. Nothing special here. =cut sub new { my ($class, %self) = @_; return bless \%self, $class; } =head2 factory Net::AMQP::Frame->factory( type_id => 1, channel => 1, payload => '', ); Will attempt to identify a L subclass for further parsing, and will croak on failure. Returns a L subclass object. =cut sub factory { my ($class, %args) = @_; unless (exists $args{type_id}) { croak "Mandatory parameter 'type_id' missing in call to Net::AMQP::Frame::factory"; } unless (exists $args{channel}) { croak "Mandatory parameter 'channel' missing in call to Net::AMQP::Frame::factory"; } unless (exists $args{payload}) { croak "Mandatory parameter 'payload' missing in call to Net::AMQP::Frame::factory"; } unless (keys %args == 3) { croak "Invalid parameter passed in call to Net::AMQP::Frame::factory"; } my $subclass; if ($args{type_id} == 1) { $subclass = 'Method'; } elsif ($args{type_id} == 2) { $subclass = 'Header'; } elsif ($args{type_id} == 3) { $subclass = 'Body'; } elsif ($args{type_id} == 8) { $subclass = 'Heartbeat'; } else { croak "Unknown type_id $args{type_id}"; } $subclass = 'Net::AMQP::Frame::' . $subclass; my $object = bless \%args, $subclass; $object->parse_payload(); return $object; } =head1 OBJECT METHODS =head2 Field accessors Each subclass extends these accessors, but they share in common the following: =over 4 =item I =item I =item I =item I =back =head2 parse_payload Performs the parsing of the 'payload' binary data. =head2 to_raw_payload Returns the binary data the represents this frame's payload. =head2 to_raw_frame Returns a raw binary string representing this frame on the wire. =cut sub to_raw_frame { my $self = shift; my $class = ref $self; if (! defined $self->channel) { $self->channel(0); } return pack('Cn', $self->type_id, $self->channel) . pack_long_string($self->to_raw_payload()) . pack('C', 206); } =head2 type_string Returns a string that uniquely represents this frame type, such as 'Method Basic.Consume', 'Header Basic' or 'Body' =cut sub type_string { my $self = shift; my ($type) = ref($self) =~ m{::([^:]+)$}; my $subtype; if ($self->can('method_frame')) { ($subtype) = ref($self->method_frame) =~ m{^Net::AMQP::Protocol::(.+)$}; my ($class, $method) = split /::/, $subtype; $subtype = join '.', $class, $method; } elsif ($self->can('header_frame')) { ($subtype) = ref($self->header_frame) =~ m{^Net::AMQP::Protocol::(.+)::ContentHeader$}; } return $type . ($subtype ? " $subtype" : ''); } =head1 SEE ALSO L =head1 COPYRIGHT Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. =head1 AUTHOR Eric Waters =cut 1; Net-AMQP-0.06~dfsg/lib/Net/AMQP/Protocol.pm0000444000000000000000000002261012140350635016650 0ustar rootrootpackage Net::AMQP::Protocol; =head1 NAME Net::AMQP::Protocol - Loading code of the AMQP spec =head1 DESCRIPTION This class serves as a loader for the auto-generated classes of the protocol. =cut use strict; use warnings; use Net::AMQP::Common qw(:all); use Net::AMQP::Protocol::Base; use XML::LibXML; use File::Path; use File::Spec; our ($VERSION_MAJOR, $VERSION_MINOR, $VERSION_REVISION, %spec); =head1 CLASS METHODS =head2 header Returns a binary string representing the header of any AMQP communications =cut sub header { 'AMQP' . pack 'C*', 1, 1, $VERSION_MAJOR, $VERSION_MINOR; } =head2 load_xml_spec Pass in the XML filename. Reads in the AMQP XML specifications file, XML document node , and generates subclasses of L for each frame type. Names are normalized, as demonstrated by this example: creates the class L with the field accessor C, allowing you to create a new object as such: my $method = Net::AMQP::Protocol::Basic::ConsumeOk->new( consumer_tag => 'blah' ); print $method->consumer_tag() . "\n"; if ($method->class_id == 60 && $method->method_name == 21) { # do something } =cut sub load_xml_spec { my ($class, $xml_fn, $xml_str_ref) = @_; my $parser = XML::LibXML->new(); my $doc = defined $xml_fn ? $parser->parse_file($xml_fn) : $parser->parse_string($$xml_str_ref); my $root = $doc->documentElement; # Header if ($root->nodeName ne 'amqp') { die "Invalid document node name ".$root->nodeName; } #print "Using spec from '" . $root->getAttribute('comment') . "'\n"; $VERSION_MAJOR = $root->getAttribute('major'); $VERSION_MINOR = $root->getAttribute('minor'); $VERSION_REVISION = $root->getAttribute('revision'); foreach my $child ($root->childNodes) { my $nodeName = $child->nodeName; my %attr = map { $_->name => $_->getValue } grep { defined $_ } $child->attributes; if ($nodeName =~ m{^(constant|domain)$}) { $spec{$nodeName}{ $attr{name} } = { map { $_ => $attr{$_} } grep { $_ ne 'name' } keys %attr }; } elsif ($nodeName eq 'class') { my %class = ( name => _normalize_name($attr{name}), class_id => $attr{index}, handler => $attr{handler}, ); foreach my $child_method ($child->getChildrenByTagName('method')) { my %method = ( name => _normalize_name($child_method->getAttribute('name')), method_id => $child_method->getAttribute('index'), synchronous => $child_method->getAttribute('synchronous'), content => $child_method->getAttribute('content'), responses => {}, ); foreach my $child_field ($child_method->getChildrenByTagName('field')) { my $field = { map { $_->name => $_->getValue } grep { defined $_ } $child_field->attributes }; my @doc; if ($child_field->firstChild && $child_field->firstChild->nodeType == 3) { @doc = ( $child_field->firstChild->textContent ); } foreach my $doc ($child_field->getChildrenByTagName('doc')) { next if $doc->hasAttribute('name'); push @doc, $doc->textContent; } foreach my $i (0 .. $#doc) { $doc[$i] =~ s{[\n\t]}{ }g; $doc[$i] =~ s{\s{2,}}{ }g; $doc[$i] =~ s{^\s*}{}; } $field->{doc} = join "\n\n", @doc; push @{ $method{fields} }, $field; } foreach my $child_response ($child_method->getChildrenByTagName('response')) { my $name = _normalize_name($child_response->getAttribute('name')); $method{responses}{$name} = 1; } push @{ $class{methods} }, \%method; } # Parse class-level fields (for ContentHeader) my @class_fields = $child->getChildrenByTagName('field'); if (@class_fields) { my @fields; foreach my $child_field (@class_fields) { push @fields, { map { $_->name => $_->getValue } grep { defined $_ } $child_field->attributes }; } # Create a virtual class method push @{ $class{methods} }, { name => 'ContentHeader', method_id => 0, # FIXME: Will this conflict? This is for internal use only. Make constant maybe? synchronous => undef, responses => {}, fields => \@fields, }; } $spec{class}{$class{name}} = \%class; _build_class(\%class); } } } sub _normalize_name { my $name = shift; # Uppercase the first letter of each word $name =~ s{\b(.+?)\b}{\u$1}g; # Remove hyphens $name =~ s{-}{}g; return $name; } sub _build_class { my $class_spec = shift; my $base_class_name = 'Net::AMQP::Protocol::' . $class_spec->{name}; foreach my $method_spec (@{ $class_spec->{methods} }) { my $method_class_name = $base_class_name . '::' . $method_spec->{name}; my @frame_arguments; foreach my $field_spec (@{ $method_spec->{fields} }) { my $type = $field_spec->{type}; # may be 'undef' if ($field_spec->{domain}) { $type = $spec{domain}{ $field_spec->{domain} }{type}; } if (! $type) { die "No type found for $method_class_name field $$field_spec{name}"; } my $local_type = $data_type_map{$type}; if (! $local_type) { die "Couldn't map spec type '$type' to a local name"; } my $local_name = $field_spec->{name}; $local_name =~ tr{ -}{_}; $local_name =~ tr{_}{}d if $local_name eq 'no_wait'; # AMQP spec is inconsistent push @frame_arguments, $local_name, $local_type; } # Prefix the keys of the 'responses' hash with my base class name so I # have a quick lookup table for checking if a class of message is a response # to this method (synchronous methods only) foreach my $key (keys %{ $method_spec->{responses} }) { $method_spec->{responses}{ $base_class_name . '::' . $key } = delete $method_spec->{responses}{$key}; } eval <{class_id} } sub method_id { return $method_spec->{method_id} } EOF die $@ if $@; $method_class_name->class_spec($class_spec); $method_class_name->method_spec($method_spec); $method_class_name->frame_arguments(\@frame_arguments); $method_class_name->register(); } } =head2 full_docs_to_dir Net::AMQP::Protocol->full_docs_to_dir($dir, $format); Using the dynamically generated classes, this will create 'pod' or 'pm' files in the target directory in the following format: $dir/Net::AMQP::Protocol::Basic::Publish.pod (or with format 'pm') $dir/Net/AMQP/Protocol/Basic/Publish.pm The directory will be created if it doesn't exist. =cut sub full_docs_to_dir { my ($class, $dir, $format) = @_; $class = ref $class if ref $class; $format ||= 'pod'; foreach my $service_name (sort keys %{ $spec{class} }) { foreach my $method (sort { $a->{name} cmp $b->{name} } @{ $spec{class}{$service_name}{methods} }) { my $method_class = 'Net::AMQP::Protocol::' . $service_name . '::' . $method->{name}; my $pod = $method_class->docs_as_pod; my $filename; if ($format eq 'pod') { $filename = File::Spec->catfile($dir, $method_class . '.pod'); } elsif ($format eq 'pm') { $filename = File::Spec->catfile($dir, $method_class . '.pm'); $filename =~ s{::}{/}g; } my ($volume, $directories, undef) = File::Spec->splitpath($filename); my $base_path = File::Spec->catfile($volume, $directories); -d $base_path || mkpath($base_path) || die "Can't mkpath $base_path: $!"; open my $podfn, '>', $filename or die "Can't open '$filename' for writing: $!"; print $podfn $pod; close $podfn; } } } =head1 SEE ALSO L =head1 COPYRIGHT Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. =head1 AUTHOR Eric Waters =cut 1; Net-AMQP-0.06~dfsg/lib/Net/AMQP/Common.pm0000444000000000000000000002260612140350635016304 0ustar rootrootpackage Net::AMQP::Common; use 5.006; =head1 NAME Net::AMQP::Common - A collection of exportable tools for AMQP (de)serialization =head1 SYNOPSIS use Net::AMQP::Common qw(:all) =head1 EXPORTABLE METHODS The following are available for exporting by name or by ':all'. All the 'pack_*' methods take a single argument and return a binary string. All the 'unpack_*' methods take a scalar ref and return a perl data structure of some type, consuming some data from the scalar ref. =over 4 =item I =item I =item I =item I =item I =item I =item I =item I =item I =item I =item I =item I =item I =item I =item I =item I =item I =item I =item I =item I =item I =item I =item I Tables and arrays sometimes require explicit typing. See L. Also, in tables and arrays booleans from the L module are sent as AMQP booleans. =item I =item I<%data_type_map> A mapping of the XML spec's data type names to our names ('longstr' => 'long_string') =item I A helper routine that, given a binary string, returns a string of each byte represented by '\###', base 10 numbering. =back =cut use strict; use warnings; use Scalar::Util qw( blessed reftype ); use Net::AMQP::Value; use base qw(Exporter); BEGIN { *_big = (pack('n', 1) eq pack('s', 1)) ? sub { shift } : sub { scalar reverse shift }; } our @EXPORT_OK = qw( pack_octet unpack_octet pack_short_integer unpack_short_integer pack_long_integer unpack_long_integer pack_long_long_integer unpack_long_long_integer pack_unsigned_short_integer unpack_unsigned_short_integer pack_unsigned_long_integer unpack_unsigned_long_integer pack_unsigned_long_long_integer unpack_unsigned_long_long_integer pack_timestamp unpack_timestamp pack_boolean unpack_boolean pack_short_string unpack_short_string pack_long_string unpack_long_string pack_field_table unpack_field_table pack_field_array unpack_field_array show_ascii %data_type_map ); our %EXPORT_TAGS = ( 'all' => [@EXPORT_OK], ); # The XML spec uses a abbreviated name; map this to my name our %data_type_map = ( bit => 'bit', octet => 'octet', short => 'short_integer', long => 'long_integer', longlong => 'long_long_integer', shortstr => 'short_string', longstr => 'long_string', timestamp => 'timestamp', table => 'field_table', array => 'field_array', ); sub pack_boolean { pack 'C', shift() ? 1 : 0 } sub pack_octet { pack 'C', shift || 0 } sub pack_short_integer { _big pack 's', shift || 0 } sub pack_long_integer { _big pack 'l', shift || 0 } sub pack_long_long_integer { _big pack 'q', shift || 0 } sub pack_unsigned_short_integer { pack 'n', shift || 0 } sub pack_unsigned_long_integer { pack 'N', shift || 0 } sub pack_unsigned_long_long_integer { _big pack 'Q', shift || 0 } sub unpack_boolean { unpack 'C', substr ${+shift}, 0, 1, '' } sub unpack_octet { unpack 'C', substr ${+shift}, 0, 1, '' } sub unpack_short_integer { unpack 's', _big substr ${+shift}, 0, 2, '' } sub unpack_long_integer { unpack 'l', _big substr ${+shift}, 0, 4, '' } sub unpack_long_long_integer { unpack 'q', _big substr ${+shift}, 0, 8, '' } sub unpack_unsigned_short_integer { unpack 'n', substr ${+shift}, 0, 2, '' } sub unpack_unsigned_long_integer { unpack 'N', substr ${+shift}, 0, 4, '' } sub unpack_unsigned_long_long_integer { unpack 'Q', _big substr ${+shift}, 0, 8, '' } sub pack_timestamp { goto &pack_unsigned_long_long_integer } sub unpack_timestamp { goto &unpack_unsigned_long_long_integer } sub pack_short_string { my $str = shift; $str = '' unless defined $str; return pack('C', length $str) . $str; } sub unpack_short_string { my $input_ref = shift; my $string_length = unpack 'C', substr $$input_ref, 0, 1, ''; return substr $$input_ref, 0, $string_length, ''; } sub pack_long_string { if (ref $_[0] && ref $_[0] eq 'HASH') { # It appears that, for fields that are long-string, in some cases it's # necessary to pass a field-table object, which behaves similarly. # Here for Connection::StartOk->response return pack_field_table(@_); } my $str = shift; $str = '' unless defined $str; return pack('N', length $str) . $str; } sub unpack_long_string { my $input_ref = shift; my $string_length = unpack 'N', substr $$input_ref, 0, 4, ''; return substr $$input_ref, 0, $string_length, ''; } sub pack_field_table { my $table = shift; $table = {} unless defined $table; my $table_packed = ''; foreach my $key (sort keys %$table) { # sort so I can compare raw frames my $value = $table->{$key}; $table_packed .= pack_short_string($key); $table_packed .= _pack_field_value($table->{$key}); } return pack('N', length $table_packed) . $table_packed; } sub pack_field_array { my $array = shift; $array = [] unless defined $array; my $array_packed = ''; foreach my $value (@$array) { $array_packed .= _pack_field_value($value); } return pack('N', length $array_packed) . $array_packed; } sub _pack_field_value { my ($value) = @_; if (not defined $value) { 'V' } elsif (not ref $value) { if ($value =~ /^-?\d+\z/) { 'I' . pack_long_integer($value); } else { # FIXME - assuming that all other values are string values 'S' . pack_long_string($value); } } elsif (ref($value) eq 'HASH') { 'F' . pack_field_table($value); } elsif (ref($value) eq 'ARRAY') { 'A' . pack_field_array($value); } elsif (ref($value) eq 'boolean') { 't' . pack_boolean($value); } elsif (blessed($value) && $value->isa('Net::AMQP::Value')) { $value->field_packed; } else { die "No way to pack $value into AMQP array or table"; } } my %_unpack_field_types = ( V => sub { undef }, S => \&unpack_long_string, I => \&unpack_long_integer, D => sub { my $input_ref = shift; my $exp = unpack_octet($input_ref); my $num = unpack_long_integer($input_ref); $num / 10.0 ** $exp; }, F => \&unpack_field_table, A => \&unpack_field_array, T => \&unpack_timestamp, t => \&unpack_boolean, ); sub unpack_field_table { my $input_ref = shift; my ($table_length) = unpack 'N', substr $$input_ref, 0, 4, ''; my $table_input = substr $$input_ref, 0, $table_length, ''; my %table; while (length $table_input) { my $field_name = unpack_short_string(\$table_input); my ($field_value_type) = substr $table_input, 0, 1, ''; my $field_value_subref = $_unpack_field_types{$field_value_type}; die "No way to unpack field '$field_name' type '$field_value_type'" unless defined $field_value_subref; my $field_value = $field_value_subref->(\$table_input); die "Failed to unpack field '$field_name' type '$field_value_type' ('$table_input')" unless defined $field_value; $table{ $field_name } = $field_value; } return \%table; } sub unpack_field_array { my $input_ref = shift; my ($array_length) = unpack 'N', substr $$input_ref, 0, 4, ''; my $array_input = substr $$input_ref, 0, $array_length, ''; my @array; while (length $array_input) { my $field_value_type = substr $array_input, 0, 1, ''; my $field_value_subref = $_unpack_field_types{$field_value_type}; die "No way to unpack field array element ".@array." type '$field_value_type'" unless defined $field_value_subref; my $field_value = $field_value_subref->(\$array_input); die "Failed to unpack field array element ".@array." type '$field_value_type' ('$array_input')" unless defined $field_value; push @array, $field_value; } return \@array; } sub show_ascii { my $input = shift; my $return = ''; foreach my $char (split(//, $input)) { my $num = unpack 'C', $char; if (0 && $char =~ m{^[0-9A-Za-z]$}) { $return .= $char; } else { $return .= sprintf '\%03d', $num; } } return $return; } =head1 SEE ALSO L =head1 COPYRIGHT Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. =head1 AUTHOR Eric Waters =cut 1; Net-AMQP-0.06~dfsg/lib/Net/AMQP.pm0000444000000000000000000000765412140350635015062 0ustar rootrootpackage Net::AMQP; =head1 NAME Net::AMQP - Advanced Message Queue Protocol (de)serialization and representation =head1 SYNOPSIS use Net::AMQP; Net::AMQP::Protocol->load_xml_spec('amqp0-8.xml'); ... my @frames = Net::AMQP->parse_raw_frames(\$input); ... foreach my $frame (@frames) { if ($frame->can('method_frame') && $frame->method_frame->isa('Net::AMQP::Protocol::Connection::Start')) { my $output = Net::AMQP::Frame::Method->new( channel => 0, method_frame => Net::AMQP::Protocol::Connection::StartOk->new( client_properties => { ... }, mechanism => 'AMQPLAIN', locale => 'en_US', response => { LOGIN => 'guest', PASSWORD => 'guest', }, ), ); print OUT $output->to_raw_frame(); } } =head1 DESCRIPTION This module implements the frame (de)serialization and representation of the Advanced Message Queue Protocol (http://www.amqp.org/). It is to be used in conjunction with client or server software that does the actual TCP/IP communication. =cut use strict; use warnings; use Net::AMQP::Protocol; use Net::AMQP::Frame; use Net::AMQP::Value; use Carp; our $VERSION = 0.06; use constant { _HEADER_LEN => 7, # 'CnN' _FOOTER_LEN => 1, # 'C' }; =head1 CLASS METHODS =head2 parse_raw_frames Net::AMQP->parse_raw_frames(\$binary_payload) Given a scalar reference to a binary string, return a list of L objects, consuming the data in the string. Croaks on invalid input. =cut sub parse_raw_frames { my ($class, $input_ref) = @_; my @frames; while (length($$input_ref) >= _HEADER_LEN + _FOOTER_LEN) { my ($type_id, $channel, $size) = unpack 'CnN', $$input_ref; last if length($$input_ref) < _HEADER_LEN + $size + _FOOTER_LEN; substr $$input_ref, 0, _HEADER_LEN, ''; my $payload = substr $$input_ref, 0, $size, ''; my $frame_end_octet = unpack 'C', substr $$input_ref, 0, _FOOTER_LEN, ''; if ($frame_end_octet != 206) { croak "Invalid frame-end octet ($frame_end_octet)"; } push @frames, Net::AMQP::Frame->factory( type_id => $type_id, channel => $channel, payload => $payload, ); } return @frames; } =head1 SEE ALSO L, L, L, L, L =head1 AMQP VERSIONS AMQP 0-8 is fully supported. AMQP 0-9, 0-9-1, and 0-10 are usably supported. There are interoperability issues with table encodings because the standard disagrees with the dialects of major implementations (RabbitMQ and Qpid). For now, Net::AMQP limits itself to universally agreed table elements. See L for details. AMQP 1.0 has not been tested. =head1 TODO Address the dialect problem, either via modified spec files that completely control the wire protocol, or by programmatic request. The former has precedent (viz L), but could cause a combinatorial explosion as more brokers and versions are added. The latter adds interface complexity. =head1 QUOTES "All problems in computer science can be solved by another level of indirection." -- David Wheeler's observation "...except for the problem of too many layers of indirection." -- Kevlin Henney's corollary =head1 COPYRIGHT Copyright (c) 2009 Eric Waters and XMission LLC (http://www.xmission.com/). Copyright (c) 2012, 2013 Chip Salzenberg and Topsy Labs (http://labs.topsy.com/). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. =head1 AUTHOR Eric Waters =cut 1; Net-AMQP-0.06~dfsg/META.yml0000444000000000000000000000346212140350635013734 0ustar rootroot--- abstract: 'Advanced Message Queue Protocol (de)serialization and representation' author: - 'Eric Waters ' build_requires: File::Temp: 0.19 Test::Deep: 0 Test::More: 0.88 configure_requires: Module::Build: 0.40 dynamic_config: 1 generated_by: 'Module::Build version 0.4004, CPAN::Meta::Converter version 2.130880' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Net-AMQP provides: Net::AMQP: file: lib/Net/AMQP.pm version: 0.06 Net::AMQP::Common: file: lib/Net/AMQP/Common.pm Net::AMQP::Frame: file: lib/Net/AMQP/Frame.pm Net::AMQP::Frame::Body: file: lib/Net/AMQP/Frame/Body.pm Net::AMQP::Frame::Header: file: lib/Net/AMQP/Frame/Header.pm Net::AMQP::Frame::Heartbeat: file: lib/Net/AMQP/Frame/Heartbeat.pm Net::AMQP::Frame::Method: file: lib/Net/AMQP/Frame/Method.pm Net::AMQP::Frame::OOBBody: file: lib/Net/AMQP/Frame/OOBBody.pm Net::AMQP::Frame::OOBHeader: file: lib/Net/AMQP/Frame/OOBHeader.pm Net::AMQP::Frame::OOBMethod: file: lib/Net/AMQP/Frame/OOBMethod.pm Net::AMQP::Frame::Trace: file: lib/Net/AMQP/Frame/Trace.pm Net::AMQP::Protocol: file: lib/Net/AMQP/Protocol.pm Net::AMQP::Protocol::Base: file: lib/Net/AMQP/Protocol/Base.pm Net::AMQP::Protocol::v0_8: file: lib/Net/AMQP/Protocol/v0_8.pm Net::AMQP::Value: file: lib/Net/AMQP/Value.pm Net::AMQP::Value::Boolean: file: lib/Net/AMQP/Value.pm Net::AMQP::Value::Integer: file: lib/Net/AMQP/Value.pm Net::AMQP::Value::String: file: lib/Net/AMQP/Value.pm Net::AMQP::Value::Timestamp: file: lib/Net/AMQP/Value.pm requires: Class::Accessor: 0 Class::Data::Inheritable: 0 Scalar::Util: 0 XML::LibXML: 0 resources: license: http://dev.perl.org/licenses/ version: 0.06 Net-AMQP-0.06~dfsg/MANIFEST0000444000000000000000000000126612140350635013614 0ustar rootrootBuild.PL lib/Net/AMQP.pm lib/Net/AMQP/Common.pm lib/Net/AMQP/Frame.pm lib/Net/AMQP/Frame/Body.pm lib/Net/AMQP/Frame/Header.pm lib/Net/AMQP/Frame/Heartbeat.pm lib/Net/AMQP/Frame/Method.pm lib/Net/AMQP/Frame/OOBBody.pm lib/Net/AMQP/Frame/OOBHeader.pm lib/Net/AMQP/Frame/OOBMethod.pm lib/Net/AMQP/Frame/Trace.pm lib/Net/AMQP/Protocol.pm lib/Net/AMQP/Protocol/v0_8.pm lib/Net/AMQP/Protocol/Base.pm lib/Net/AMQP/Value.pm LICENSE MANIFEST This list of files META.yml META.json README CHANGES spec/amqp0-8.xml spec/amqp0-9.xml spec/amqp0-9-1.xml spec/amqp0-10.xml spec/qpid.amqp0-8.xml t/01_basic.t t/02_ruby_protocol_doc.t t/03_standalone_0_8.t t/04_table.t t/50_autodocs.t eg/bench.pl Makefile.PL Net-AMQP-0.06~dfsg/eg/0000755000000000000000000000000012140350635013053 5ustar rootrootNet-AMQP-0.06~dfsg/eg/bench.pl0000444000000000000000000000467612140350635014502 0ustar rootroot#!/usr/bin/perl use lib './lib'; use Net::AMQP; use Net::AMQP::Protocol::v0_8; use Benchmark; sub serialize { # Message publish (code mimics AnyEvent::RabbitMQ::Channel->publish) my %args; my $header_args = { reply_to => 'foobar' }; my $body = 'AAAAAAAAAAAAAAAAAAAAAA'; my $frame_publish = Net::AMQP::Protocol::Basic::Publish->new( exchange => '', mandatory => 0, immediate => 0, %args, # routing_key ticket => 0, ); my $frame_header = Net::AMQP::Frame::Header->new( weight => $header_args->{weight} || 0, body_size => length($body), header_frame => Net::AMQP::Protocol::Basic::ContentHeader->new( content_type => 'application/octet-stream', content_encoding => undef, headers => {}, delivery_mode => 1, priority => 1, correlation_id => 1234, expiration => undef, message_id => undef, timestamp => time, type => undef, user_id => 'guest', app_id => undef, cluster_id => undef, %$header_args, ), ); my $frame_body = Net::AMQP::Frame::Body->new( payload => $body ); $frame_publish = $frame_publish->frame_wrap; $frame_publish->channel(1); $frame_header->channel(1); $frame_body->channel(1); my $raw_frames = $frame_publish->to_raw_frame . $frame_header->to_raw_frame . $frame_body->to_raw_frame ; return $raw_frames; } sub deserialize { my $raw_frames = shift; my @frames = Net::AMQP->parse_raw_frames(\$raw_frames); } # Once a connection is stablished, most common operations should be publish # and consume messages (and maybe ack?). Benchmark these operations, without # taking account for overhead introduced by event loop and i/o. # On my old mobile Core Duo 1.66 Ghz, I got: # # Benchmark: timing 5000 iterations of deserialize, serialize ... # deserialize: 1 wallclock secs ( 0.94 usr + 0.00 sys = 0.94 CPU) @ 5319.15/s (n=5000) # serialize : 1 wallclock secs ( 0.92 usr + 0.01 sys = 0.93 CPU) @ 5376.34/s (n=5000) my $raw_frames = serialize(); my @frames = deserialize($raw_frames); timethese( 5000, { 'serialize ' => sub { serialize() }, 'deserialize' => sub { deserialize($raw_frames) }, }); Net-AMQP-0.06~dfsg/Makefile.PL0000444000000000000000000000226312140350635014433 0ustar rootroot# Note: this file was auto-generated by Module::Build::Compat version 0.4004 unless (eval "use Module::Build::Compat 0.02; 1" ) { print "This module requires Module::Build to install itself.\n"; require ExtUtils::MakeMaker; my $yn = ExtUtils::MakeMaker::prompt (' Install Module::Build now from CPAN?', 'y'); unless ($yn =~ /^y/i) { die " *** Cannot install without Module::Build. Exiting ...\n"; } require Cwd; require File::Spec; require CPAN; # Save this 'cause CPAN will chdir all over the place. my $cwd = Cwd::cwd(); CPAN::Shell->install('Module::Build::Compat'); CPAN::Shell->expand("Module", "Module::Build::Compat")->uptodate or die "Couldn't install Module::Build, giving up.\n"; chdir $cwd or die "Cannot chdir() back to $cwd: $!"; } eval "use Module::Build::Compat 0.02; 1" or die $@; Module::Build::Compat->run_build_pl(args => \@ARGV); my $build_script = 'Build'; $build_script .= '.com' if $^O eq 'VMS'; exit(0) unless(-e $build_script); # cpantesters convention require Module::Build; Module::Build::Compat->write_makefile(build_class => 'Module::Build');