Accept error_cb parameter on Connection new()

Signed-off-by: Pedro Melo <melo@simplicidade.org>
Add client_id and hostname parameters to Reader new()

Signed-off-by: Pedro Melo <melo@simplicidade.org>
Refactor Connection creation in Reader:

* easier to understand;
* added support for client_id and hostname from Reader => Connection.

Signed-off-by: Pedro Melo <melo@simplicidade.org>
Tidy

Signed-off-by: Pedro Melo <melo@simplicidade.org>
A simple consumer and a HTTP-based publisher, useful for simple benchmarks

Signed-off-by: Pedro Melo <melo@simplicidade.org>
Fix: make sure consumer.pl can find the AnyEvent::NSQ::Reader lib

Signed-off-by: Pedro Melo <melo@simplicidade.org>
Catch and warn of errors, exit the script if one shows up

Signed-off-by: Pedro Melo <melo@simplicidade.org>
The message already has most of the important stuff

Signed-off-by: Pedro Melo <melo@simplicidade.org>
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 <melo@simplicidade.org>
Add support for requeue_delay on constructors, used on REQ responses

Signed-off-by: Pedro Melo <melo@simplicidade.org>
Default error_cb now carps, doesn't croak

Too aggresive, given that after an error we always disconnect.

Signed-off-by: Pedro Melo <melo@simplicidade.org>
Add support for connect_timeout on both Reader and Connection constructors

Signed-off-by: Pedro Melo <melo@simplicidade.org>
Hide the call to error_cb in a new method _log_error, API changes:

The new error_cb will still receive the same two first parameters, the
connection object and the raw error, but will also receive a third
parameter, more user friendly error message.

Signed-off-by: Pedro Melo <melo@simplicidade.org>
Fix: wrong requeue_msg() impl fixed, with support for requeue_delay

Signed-off-by: Pedro Melo <melo@simplicidade.org>
Add touch_msg() API

Signed-off-by: Pedro Melo <melo@simplicidade.org>
Refactor _start_recv_frames into smaller methods:

* added _process_incoming_frame to pick the correct frame type processor;
* added _process_success_frame, _process_error_frame and
  _process_message_frame:
  * they should return undef to give up;
  * or any truth value to keep reading frames.
* renamed _on_success_frame to _on_next_success_frame;
* we no longer die on unknown frame types, we just ignore them.

Signed-off-by: Pedro Melo <melo@simplicidade.org>
Fix: on disconnect, make sure we cleanup the correct attributes

Signed-off-by: Pedro Melo <melo@simplicidade.org>
No need to destroy the handle on _force_disconnect, _disconnected does it

Signed-off-by: Pedro Melo <melo@simplicidade.org>
Remove old debug information

Signed-off-by: Pedro Melo <melo@simplicidade.org>
Tidy identify, single write with all the data

Signed-off-by: Pedro Melo <melo@simplicidade.org>