65 Commits

Author SHA1 Message Date
Pedro Melo
f3fb375d10 Fix memory leak, circular reference on publish()
Reported, analised and fixed by Tiago Quintela and Nuno Mota.

Signed-off-by: Pedro Melo <melo@simplicidade.org>
2015-02-28 07:49:45 +00:00
Pedro Melo
1c5a3526fd Tidy
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2015-01-02 12:46:29 +00:00
Pedro Melo
f56271c965 Refactor _find_and_delete_message_connection as _find_message_connection:
Not all commands need the delete part, touch_msg for example

Signed-off-by: Pedro Melo <melo@simplicidade.org>
2015-01-02 12:46:23 +00:00
Pedro Melo
681939809d Rename touch_message to touch_msg, for consistency:
Kept the old name around for now...

Signed-off-by: Pedro Melo <melo@simplicidade.org>
2015-01-02 12:45:22 +00:00
Pedro Melo
dca911fee8 Tidy
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-10-23 07:08:45 +01:00
Pedro Melo
a08049ee0f Add ready() to ::Client
Allow clients to update the ready count dynamically

Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-10-23 07:08:41 +01:00
Bruno Tavares
a9e3803889 Merge pull request #4 from tavaresb/master
Interface to issue message commands
2014-09-10 17:23:14 +01:00
Bruno Tavares
f2cf93d8e5 no need to allocate a variable that has no use 2014-09-10 17:17:06 +01:00
Bruno Tavares
05bea0dcb8 Lost debugging lines. 2014-09-09 11:59:43 +01:00
Bruno Tavares
24b1335000 Better routing clean up. Now requires explicit message handling 2014-09-09 11:54:11 +01:00
Pedro Melo
3d57b5247b Merge pull request #3 from tavaresb/master
Bugfix: Keep the original 'identified' callback
2014-09-09 09:06:03 +01:00
Bruno Tavares
78c4ca959f Make the connection references weak references. 2014-09-03 18:22:22 +01:00
Bruno Tavares
73801c8488 interface methods to message commands on the connection 2014-09-03 11:03:14 +01:00
Bruno Tavares
ee0b61582a allow to issue commands with message id ( and message structs ) 2014-09-03 11:02:54 +01:00
Bruno Tavares
7edb6bbfa0 Connection routing registry 2014-09-03 10:19:11 +01:00
Bruno Tavares
e8ca613154 Keep te original 'identified' callback 2014-09-03 09:59:46 +01:00
Pedro Melo
ad113aed07 Merge pull request #2 from tavaresb/master
Bugfix: Connection callbacks
2014-09-03 05:12:10 +01:00
Bruno Tavares
7b89af5b97 Identation 2014-09-02 18:23:07 +01:00
Bruno Tavares
1f0042b10b FIX: Save the connection state callbacks 2014-09-02 18:21:48 +01:00
Pedro Melo
e6cbc372cc On disconnect() send CLS only if this connection is a subscriber
If no SUB was sent before, CLS returns error:

> E_INVALID cannot CLS in current state

Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-21 05:52:34 +01:00
Pedro Melo
d807d361f3 Add --stats support for consumer:
Gives stats over the last 10 seconds, plus global rate.

Use with http_publisher.pl to test your consumer performance.

Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-21 05:47:33 +01:00
Pedro Melo
b69bd4a19b Make consumer.pl trap SIGINT and SIGTERM, disconnect cleanly
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-21 05:20:45 +01:00
Pedro Melo
cfa7a7b4a5 Move publish() public API to Client, even Readers get to publish sometimes
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-21 05:16:17 +01:00
Pedro Melo
0d8f13b950 Update publish() on both Connection and Writer to use MPUB if need be:
We accept a list of messages now, before the trailing optional callback.

If multiple messages are present, we switch to MPUB.

Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-21 05:13:36 +01:00
Pedro Melo
1ff696d616 Add support for the factors parameter in publisher.pl:
We can multiply the number of messages delivery by factor, thus allowing
to test support for publishing multiple messages

Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-21 05:11:43 +01:00
Pedro Melo
5bd01740ee Improve consumer.pl:
* use Getopt::Long to enable/disable help, verbose and print mode;
* add proper usage message;
* keep track of total messages received.

Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-21 05:10:39 +01:00
Pedro Melo
71c97d864c Simple TCP publisher, reads STDIN, publishes one message per line
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 22:14:20 +01:00
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
3e54c101f4 Tidy
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 19:50:36 +01:00
Pedro Melo
35e310fd07 Tweak consumer to use the new disconnect_cb
Signed-off-by: Pedro Melo <melo@simplicidade.org>
2014-07-20 19:50:36 +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