[nanomsg] modular nn_device

  • From: Drew Crawford <drew@xxxxxxxxxxxxxxxxxx>
  • To: nanomsg@xxxxxxxxxxxxx
  • Date: Thu, 12 Jun 2014 08:44:07 -0500

I’m wondering if there is any interest in improving the modularity of nn_device.

If you look at the current design, there are a bunch of functions that you get 
as a set:

nn_device, which performs a series of checks, none of which are configurable
A series of nn_device_nway functions that implement various polling schemes
an nn_device_mvmsg function that copies a message from here to there

Lately I have been writing some devices that are roughly 90% nn_device and 10% 
something else.  For example I have an nn_caching_device that learns how to 
answer certain requests without asking the other socket.  I have an 
nn_hub_device that sends a request to one of several workers based on criteria. 
 I have devices that know how to bridge protocol types that are not ordinarily 
compatible.  etc.

My current strategy to build these is basically to copy device.c into a new 
file and make edits as appropriate, but obviously this is wasteful and is a 
poor design for the kind of experiments I’m doing.

I’m wondering if there’s interest in me working on making device.c more 
modular.  Specifically I’m thinking about creating some kind of vfptr structure 
where you can specify a device by creating a struct with function pointers that 
define the device’s behavior, so that I custom devices would be able to 
override the base device piecemeal rather than all at once.


Other related posts: