gakpinet 0.2.9
# inet**v0.2.4 has bug so you'll have to clone the head**A simple library built on top of zeromq to enable different pythonprograms talk over sockets. It works using three components*server*, *name service* and *client*. The main feature(or use) of thislibrary is its persistent name service### Name ServiceStart the inet server on command line```shell$ inetserver```### ServerThe server is a function to respond to requests```pythonfrom inet.inetclient import InetClientfrom inet.server import RoutableServer# talks with the inet serverproxy = InetClient('tcp://127.0.0.1:3014')# frontend address is what clients connect to while backend address(unix socket)# is what workers connect toserver = RoutableServer('testservice', proxy, 'tcp://127.0.0.1:4001', 'ipc:///tmp/inet.testservice.sock')@server.route('hello/world')def hello(req, resp): resp.data['greeting'] = 'World' return respserver.setup(localproxy=False)# spawn default(3) number of workersserver.spawnworkers()server.loopforever()```### Client```pythonfrom inet.inetclient import InetClientfrom inet.client import Clientproxy = InetClient('tcp://127.0.0.1:3014')client = Client(proxy)# service name acts as protocolresp = client.get('testservice://hello/world')print(resp.meta['status']) # 200print(resp.data['greeting']) # 'World'```*N.B*: Notes that it uses gevent for managing workers
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.