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.

Filename, size & hash SHA256 hash help File type Python version Upload date
service_factory-0.1.5-py2-none-any.whl (10.1 kB) Copy SHA256 hash SHA256 Wheel py2
service_factory-0.1.5-py3-none-any.whl (10.1 kB) Copy SHA256 hash SHA256 Wheel py3
service_factory-0.1.5.tar.gz (17.6 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page