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 details)

Uploaded Source

File details

Details for the file service_factory-0.1.6.tar.gz.

File metadata

  • Download URL: service_factory-0.1.6.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for service_factory-0.1.6.tar.gz
Algorithm Hash digest
SHA256 abd8e715e2d32ee83ea4bbe365d34e0f94e3068ec03683f09f4512f657e1cd64
MD5 5b5262193170fb062d54c4eaa7fb39a1
BLAKE2b-256 33155beb1df57ec538bfa48f61f34a8de6061139ff7aca0f2bcf30b525bc07cb

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