nanoconfig is a small wrapper on top of nanomsg that lets admins configure nanomsg sockets without programmers intervention.
The goal for nanoconfig is to be enventually included into nanomsg itself.
Any nanomsg socket can be configured with nanoconfig. To do this, instead of
calling nn_bind() and nn_connect() and setting various socket options
do single nc_configure() call. For example:
#include <nanomsg/nn.h> #include <nanomsg/reqrep.h> #include <nanomsg/nanoconfig.h> s = nn_socket (AF_SP, AF_SP_RAW) assert (s >= 0) rc = nc_configure(s, "nanoconfig://topology1") assert (rc >= 0) ... nc_close (s);
Note: instead of raw nn_close from nanomsg you must call nc_close from
nanoconfig, so that nanoconfig can free it's own resources.
You should set the address of configuration service using environment variable.
For example, if you have your_app binary application:
NN_CONFIG_SERVICE=ipc:///var/run/name_service.sock your_app
To have system-wide configuration service you might want to
add /etc/profile.d/nanoconfig.sh with the following contents:
NN_CONFIG_SERVICE=ipc:///var/run/name_service.sock export NN_CONFIG_SERVICE
There are two command-line programs, that are useful for debugging and experimentation with nanoconfig:
nccatis just same utility thenanocatis but instead of--bindand--connectoptions it has--topologyoptionncdevis a thin wrapper aroundnn_devicethat should transparently join the topology
There is a very dumb configuration service in examples directory. You can
run it with:
cd examples python2 ns.py
See examples/README.rst for list of dependencies.
More configuration service implementation will be listed later.
nanomsg website: http://nanomsg.org