nanoservice is a small Python library for writing lightweight networked services using nanomsg
With nanoservice you can break up monolithic applications into small, specialized services which communicate with each other.
- Make sure you have the nanomsg library installed:
$ git clone [email protected]:nanomsg/nanomsg.git
$ ./configure
$ make
$ make check
$ sudo make installFor more details visit the official nanomsg repo
On OS X you can also do:
$ brew install nanomsg- Install nanoservice:
From project directory
$ make installOr via pip
$ pip install nanoservice (it's broken)The service:
from nanoservice import Responder
def echo(msg):
return msg
s = Responder('ipc:///tmp/service.sock')
s.register('echo', echo)
s.start()$ python echo_service.pyThe client:
from nanoservice import Requester
c = Requester('ipc:///tmp/service.sock')
res, err = c.call('echo', 'hello world’)
print('Result is {}'.format(res))$ python my_client.py
$ Result is: hello worldTo run tests:
$ make testTo run benchmarks
$ make benchCheck out examples directory for more examples.
MIT Licensed