Stable old version of inet
Project description
# 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 python
programs talk over sockets. It works using three components
*server*, *name service* and *client*. The main feature(or use) of this
library is its persistent name service
### Name Service
Start the inet server on command line
```shell
$ inetserver
```
### Server
The server is a function to respond to requests
```python
from inet.inetclient import InetClient
from inet.server import RoutableServer
# talks with the inet server
proxy = InetClient('tcp://127.0.0.1:3014')
# frontend address is what clients connect to while backend address(unix socket)
# is what workers connect to
server = 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 resp
server.setup(localproxy=False)
# spawn default(3) number of workers
server.spawnworkers()
server.loopforever()
```
### Client
```python
from inet.inetclient import InetClient
from inet.client import Client
proxy = InetClient('tcp://127.0.0.1:3014')
client = Client(proxy)
# service name acts as protocol
resp = client.get('testservice://hello/world')
print(resp.meta['status']) # 200
print(resp.data['greeting']) # 'World'
```
*N.B*: Notes that it uses gevent for managing workers
**v0.2.4 has bug so you'll have to clone the head**
A simple library built on top of zeromq to enable different python
programs talk over sockets. It works using three components
*server*, *name service* and *client*. The main feature(or use) of this
library is its persistent name service
### Name Service
Start the inet server on command line
```shell
$ inetserver
```
### Server
The server is a function to respond to requests
```python
from inet.inetclient import InetClient
from inet.server import RoutableServer
# talks with the inet server
proxy = InetClient('tcp://127.0.0.1:3014')
# frontend address is what clients connect to while backend address(unix socket)
# is what workers connect to
server = 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 resp
server.setup(localproxy=False)
# spawn default(3) number of workers
server.spawnworkers()
server.loopforever()
```
### Client
```python
from inet.inetclient import InetClient
from inet.client import Client
proxy = InetClient('tcp://127.0.0.1:3014')
client = Client(proxy)
# service name acts as protocol
resp = client.get('testservice://hello/world')
print(resp.meta['status']) # 200
print(resp.data['greeting']) # 'World'
```
*N.B*: Notes that it uses gevent for managing workers
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
gakp_inet-0.2.9-py3-none-any.whl
(11.8 kB
view details)
File details
Details for the file gakp_inet-0.2.9-py3-none-any.whl.
File metadata
- Download URL: gakp_inet-0.2.9-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9821e975620a59cba0ab34abeb6c4b560db35d570e737e1953778a55b5b7e22
|
|
| MD5 |
e9fe37e359abf773d26f2fafd87bea76
|
|
| BLAKE2b-256 |
0c9e05bff4143692bf9b24f2a1ab019bfea3fee05cb259e5c957d926602f01c8
|