Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Revision history for Perl extension AnyEvent::RabbitMQ

- Add "nodelay" option to disable Nagle's algorithm.
https://rt.cpan.org/Ticket/Display.html?id=119793
Also José Micó's e888205306fb49167c0dc9aa4e4dc940cc922d25.
- Assign a version number to all modules in package.

1.21 Sat 30 May 23:40:54 BST 2020
Expand Down
2 changes: 2 additions & 0 deletions dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ x_contributors = Masahito Ikuta <cooldaemon@gmail.com>
x_contributors = Rod Taylor <rod.taylor@gmail.com>
x_contributors = Carl Hörberg <carl@cloudamqp.com>
x_contributors = Julio Polo <julio@hawaii.edu>
x_contributors = A.J. Ragusa <aragusa@globalnoc.iu.edu>
x_contributors = José Micó

[InstallGuide]
[CPANFile]
Expand Down
2 changes: 2 additions & 0 deletions lib/AnyEvent/RabbitMQ.pm
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ sub connect {
peername => $args{host},
$args{tls} ? (tls => 'connect') : (),
$args{tls_ctx} ? ( tls_ctx => $args{tls_ctx} ) : (),
$args{nodelay} ? ( nodelay => $args{nodelay} ) : (),
);
$self->_read_loop($args{on_close}, $args{on_read_failure});
$self->_start(%args,);
Expand Down Expand Up @@ -690,6 +691,7 @@ AnyEvent::RabbitMQ - An asynchronous and multi channel Perl AMQP client.
tls => 0, # Or 1 if you'd like SSL
tls_ctx => $anyevent_tls # or a hash of AnyEvent::TLS options.
tune => { heartbeat => 30, channel_max => $whatever, frame_max = $whatever },
nodelay => 1, # Reduces latency by disabling Nagle's algorithm
on_success => sub {
my $ar = shift;
$ar->open_channel(
Expand Down
29 changes: 29 additions & 0 deletions xt/04_anyevent.t
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,35 @@ lives_ok sub {
$ar->load_xml_spec()
}, 'load xml spec';

my @nagle = [[], [nodelay => 0], [nodelay => 1]];

for my $opt (@nagle) {
my $done = AnyEvent->condvar;
my $z = AnyEvent::RabbitMQ->new(verbose => $conf{verbose});
$z->connect(
(map {$_ => $conf{$_}} qw(host port user pass vhost)),
timeout => 1,
on_success => sub {
my $ar = shift;
isa_ok($ar, 'AnyEvent::RabbitMQ');
$done->send;
},
on_failure => failure_cb($done),
on_return => sub {
my $method_frame = shift->method_frame;
die "return: ", $method_frame->reply_code, $method_frame->reply_text
if $method_frame->reply_code;
},
on_close => sub {
my $method_frame = shift->method_frame;
Carp::confess "close: ", $method_frame->reply_code, $method_frame->reply_text
if $method_frame->reply_code;
},
@{ $opt },
);
$done->recv;
}

my $done = AnyEvent->condvar;
$ar->connect(
(map {$_ => $conf{$_}} qw(host port user pass vhost)),
Expand Down