Commit Graph

31 Commits

Author SHA1 Message Date
Pedro Melo a9d7134082 Add publish() to Write
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 22:13:50 +01:00
Pedro Melo d19a76677a Add publish() to Connection, mapped to PUB command
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 22:13:40 +01:00
Pedro Melo 3c1a9a3083 Add private _random_connected_conn() to return one of the connect conns
Not really random at this moment...

Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 22:13:21 +01:00
Pedro Melo 5142b3a15a Add disconnect() to Client, closes all connected conns
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 22:12:38 +01:00
Pedro Melo 1b536cf011 Add disconnect() to Connection, using the CLS protocol command
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 22:12:14 +01:00
Pedro Melo cbc2429862 Update _process_success_frame:
If it looks like JSON, parse it as JSON. If not assume normal success
message and send it to cb inside a hash on the 'msg' key.

Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 22:11:46 +01:00
Pedro Melo d3fe82af45 Added skel for our Writer class:
It connect and identifies just fine, but no API for publishing right now.

Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 19:52:48 +01:00
Pedro Melo 6e6265053e Fix: Connection disconnect_cb/error_cb were being called in the wrong order
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 19:48:57 +01:00
Pedro Melo e57cf0cab0 Add support for disconnect_cb on ::Connection
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 19:48:15 +01:00
Pedro Melo d3df376503 Tweak ::Connection handling of *_cb parameters, more consistent errors
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 19:41:38 +01:00
Pedro Melo be0643be48 Make ::Reader use the new ::Client base class
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 19:41:06 +01:00
Pedro Melo ac565116a7 Create ::Client, extract common parts from Reader
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 19:40:50 +01:00
Pedro Melo 903fe1cbe9 Add some comments
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 17:45:48 +01:00
Pedro Melo 88b263f0d5 Tidy identify, single write with all the data
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 17:45:30 +01:00
Pedro Melo 28c97bd0a4 Remove old debug information
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 17:45:06 +01:00
Pedro Melo 4b5d7faf04 No need to destroy the handle on _force_disconnect, _disconnected does it
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 17:44:52 +01:00
Pedro Melo 0796b36244 Fix: on disconnect, make sure we cleanup the correct attributes
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 17:44:26 +01:00
Pedro Melo d7a830f0f8 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>
2014-07-20 17:43:47 +01:00
Pedro Melo 36c67c9586 Add touch_msg() API
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 17:40:13 +01:00
Pedro Melo c7c6038397 Fix: wrong requeue_msg() impl fixed, with support for requeue_delay
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 17:39:56 +01:00
Pedro Melo 522f4e1670 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>
2014-07-20 17:38:11 +01:00
Pedro Melo bfa5a905d7 Add support for connect_timeout on both Reader and Connection constructors
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 17:36:31 +01:00
Pedro Melo 011c7a4b82 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>
2014-07-20 17:35:13 +01:00
Pedro Melo be7b2c03d6 Add support for requeue_delay on constructors, used on REQ responses
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 17:34:31 +01:00
Pedro Melo dcca4aea33 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>
2014-07-20 17:32:50 +01:00
Pedro Melo 6b86255149 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>
2014-07-20 13:45:22 +01:00
Pedro Melo d48cfc068f Add client_id and hostname parameters to Reader new()
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 13:43:40 +01:00
Pedro Melo 15eef5072c Accept error_cb parameter on Connection new()
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 13:43:00 +01:00
Pedro Melo 9521132b8b Added rough subscriber code that works, lots of open issues
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 10:27:43 +01:00
Pedro Melo ceb8146410 Tweak AnyEvent::NSQ abstract and fix package name
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-19 21:57:52 +01:00
Pedro Melo 4dbb22b847 initial commit 2014-07-19 21:46:05 +01:00