[nanomsg] Re: Where "Channel ID" are managed in the code ?

  • From: Martin Sustrik <sustrik@xxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Mon, 13 Jan 2014 14:56:11 +0100

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 13/01/14 14:48, Laurent Alebarde wrote:
> Thanks Martin.
> 
> I could find: "key = nn_getl (nn_chunkref_data (&msg->hdr));" in
> xrep.c / nn_xrep_send and: "memcpy (nn_chunkref_data (&msg->hdr),
> data, i * sizeof (uint32_t));" in xrep.c / nn_xrep_recv which show
> me how to manipulate the channels IDs.
> 
> But not in rep.c
> 
> What is the difference please functionaly between REP and XREP ?
> Are some design documents available somewhere ? What makes that
> from the API, XREP will be used instead of REP ? Sorry if my
> questions may be stupid.

REP is just a wrapper on top of XREP. What it does is that it assigns
a reuest ID to each request and discards any replies with non-matching ID.

> For my stateful use case, I will pair clients and workers. So in a
> proxy belonging to the server, I will use a XREP on the client side
> and also a XREP on the worker side. First the workers register. I
> store their channel ID. Then when I receive a message from the
> client, I assign it a worker and puts the pair of channels ID in a
> hash table. I then rewrite the channel ID with "memcpy
> (nn_chunkref_data (&msg_from_client->hdr), 
> worker_channel_IS_assigned, isizeof (uint32_t));" and send this
> message to the worker.

The problem with statefull req/rep is how to handle partial failure.
If one worker dies, some clients will be stuck forever. You have to
define a mechanism for recovering from such problems.

Martin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJS0/B7AAoJENTpVjxCNN9Yb/wIAIodxk7EMoZDA3+5z3zhM8vd
GLrGN0eXiewa3r4R+ydo0NBH93FgndsrlH9Z0HCUNleWuAsm4go4DmItvpFoAUrh
Z89ZRYu9ngwyd5JDdk56sGtahkzKX3YMmiElArHX2cWq2PN6uQYLUkHmYNhmGtvO
wyV21Tt310gFOqV2flBSal62B+i1irYj6G0/ERpuk3HiBSx7xyvc8OUzUHYTCrXh
H4bK3OzWgJ2V5TG6CvxethNU6DG1X4RnrvjPj4LNsN5fl1EoATB3NZZL4LRcsEMt
FK7B+1WMiZRTpPL6IaHXq0Qd69B96GMQ0F1RdpWDsATcTkMPjMGYyS9+So/ksL8=
=R7kP
-----END PGP SIGNATURE-----

Other related posts: