Skip to main content

TCP & HTTP RPC Servers written with msgpack and gevent

Project description

GreenRPC
========

TCP & HTTP RPC Server written with [msgpack](http://msgpack.org/) and
[gevent](http://www.gevent.org/)

## Install
### pip

```bash
pip install greenrpc
```

### git
```bash
git clone git://github.com/brettlangdon/greenrpc.git
cd ./greenrpc
python setup.py install
```


## Usage
### server
```bash
$ greenrpc-server -h
usage: greenrpc-server [-h] [--bind BIND] [--spawn SPAWN] [--http] <module> [<module> ...]

Start a new GreenRPC TCP Server

positional arguments:
<module> Python module to expose for the RPC Server

optional arguments:
-h, --help show this help message and exit
--bind BIND <address>:<port> to bind the server to (default: 127.0.0.1:3434)
--spawn SPAWN number of greenlets to spawn (default: 4)
--http whether to start an http server instead of tcp (default: False)
```

Expose the python module [time](https://docs.python.org/2/library/time.html) as
an RPC server
```
$ greenrpc-server time
```

Exposing multiple modules
```
$ greenrpc-server time json
```

### cli client
```bash
$ greenrpc-client -h
usage: greenrpc-client [-h] [--connect CONNECT] [--debug] [--http] <method> [<arg> [<arg> ...]]

Start a new GreenRPC TCP Server

positional arguments:
<method> The remote method to call
<arg> Arguments to send for the remote method call

optional arguments:
-h, --help show this help message and exit
--connect CONNECT <address>:<port> of the server to connect to(default: 127.0.0.1:3434)
--debug whether or not to show the full result
--http whether the server is http or tcp
```

```
$ greenrpc-client time
1414368752.71
$ greenrpc-client --debug time
{'results': 1414368766.407974, 'run_time': 0.0059604644775390625, 'id': 1}
```

### python client
```python
from greenrpc.client import TCPClient

client = TCPClient()
print client.time()
# 1414368818.587777
print client.call("time")
# 1414368830.217749
print client.call("time", debug=True)
# {'results': 1414368849.379209, 'run_time': 0.008106231689453125, 'id': 3}
```


## License
```
The MIT License (MIT)

Copyright (c) 2014 Brett Langdon

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

greenrpc-0.1.3.tar.gz (5.5 kB view details)

Uploaded Source

File details

Details for the file greenrpc-0.1.3.tar.gz.

File metadata

  • Download URL: greenrpc-0.1.3.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for greenrpc-0.1.3.tar.gz
Algorithm Hash digest
SHA256 bcfa13d1474e7a79973c0c5109051bb6376c604f07e6b7560fa04a86227bc715
MD5 279dd1996659a95703fc261119e8fad1
BLAKE2b-256 72d7cd072cf41e66ef959f4d3e419196bd376f9f70e617f6ea5e9bb03ad1f999

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page