From dcca4aea3367ebe25f2125027e004000093af0e8 Mon Sep 17 00:00:00 2001 From: Pedro Melo Date: Sun, 20 Jul 2014 17:32:50 +0100 Subject: [PATCH] Change API for the message callback return code: * undef => mark as done (send FIN); * -1 and above, send requeue, with value specifying the delay: * >= 0 => use value as delay, 0 is a special case, means immediatly; * -1 => use number of attempts times the requeue_delay constructor parameter. Signed-off-by: Pedro Melo --- lib/AnyEvent/NSQ/Reader.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/AnyEvent/NSQ/Reader.pm b/lib/AnyEvent/NSQ/Reader.pm index 6e6c485..0d9fee5 100644 --- a/lib/AnyEvent/NSQ/Reader.pm +++ b/lib/AnyEvent/NSQ/Reader.pm @@ -96,9 +96,9 @@ sub _start_nsqd_connection { my $action = $self->{message_cb}->($self, $msg); + ## Action below -1 does nothing, we assume the user took care of it himself if (not defined $action) { $conn->mark_as_done_msg($_[1]) } - elsif ($action >= 0) { $conn->requeue_msg($_[1], $action) } - else { $conn->touch_msg($_[1], -$action) } + elsif ($action >= -1) { $conn->requeue_msg($_[1], $action) } } );