Metadata-Version: 2.0
Name: service-factory
Version: 0.1.5
Summary: JSON RPC service factory for Python.
Home-page: https://github.com/proofit404/service-factory
Author: Artem Malyshev
Author-email: proofit404@gmail.com
License: GPL3
Platform: any
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Topic :: Software Development


.. |travis| image:: https://travis-ci.org/proofit404/service-factory.png
    :target: https://travis-ci.org/proofit404/service-factory
    :alt: Build Status

.. |coveralls| image:: https://coveralls.io/repos/proofit404/service-factory/badge.png
    :target: https://coveralls.io/r/proofit404/service-factory
    :alt: Coverage Status

.. |requires| image:: https://requires.io/github/proofit404/service-factory/requirements.svg
    :target: https://requires.io/github/proofit404/service-factory/requirements
    :alt: Requirements Status

.. |landscape| image:: https://landscape.io/github/proofit404/service-factory/master/landscape.svg
    :target: https://landscape.io/github/proofit404/service-factory/master
    :alt: Code Health

===============
service-factory
===============

|travis| |coveralls| |requires| |landscape|

JSON RPC service factory for Python.

Usage
-----

Service factory in a nutshell:

.. code:: python

    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:

.. code:: bash

    $ python calc.py
    service factory starts at port 9001

See it works:

.. code:: bash

    $ 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:

.. code:: bash

    $ 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:

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.


