Skip to main content

JSON RPC service factory for Python.

Project description

Build Status Coverage Status Requirements Status Code Health

JSON RPC service factory for Python.

Usage

Service factory in a nutshell:

from service_factory import service_factory

def add(one, two):
    """Add two numbers."""
    return one + two

def mul(one, two):
    """Multiply two numbers."""
    return one * two

app = [add, mul]

if __name__ == '__main__':
    service_factory(app, host='localhost', port=0)

Run this as usual python file:

$ python calc.py
service factory starts at port 9001

See it works:

$ curl -X POST -d '{"jsonrpc": "2.0", "method": "add", "params": [1, 2], "id": 1}' -H 'Content-Type:application/json;' http://localhost:9001/

You can use any callable list from arbitrary module to run your application:

$ python -m service_factory calc:app --host=localhost --port=auto
# or
$ service_factory calc:app --host=localhost --port=auto

TODO

  • process all errors codes

  • batch processing

  • notifications

  • WSGI provider

  • tornado provider

  • aiohttp provider

  • –port-file option

  • console entry point

  • make providers act as context managers

  • user_error(code, message, data=None)

  • WSGI authorization

  • sphinx docs

  • Django user permissions for rpc method

  • Celery service implementation

  • RQ service implementation

Changelog

0.1.5 (2016-10-09)

  • Zip unsafe for setuptools.

0.1.4 (2016-09-02)

  • Use 0 port value for automatic port detection.

0.1.3 (2016-08-25)

  • Remove six library from install requires.

0.1.2 (2015-03-05)

  • Remove allowed hosts parameters from service_factory function.

0.1.1 (2015-03-05)

  • Remove wildcard parameters from service_factory function. This fix provider_cls resolution issue.

0.1.0 (2015-03-04)

  • Initial release.

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

service_factory-0.1.6.tar.gz (19.6 kB view hashes)

Uploaded Source

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