tinyrpc


Nametinyrpc JSON
Version 1.1.7 PyPI version JSON
download
home_pagehttp://github.com/mbr/tinyrpc
SummaryA small, modular, transport and protocol neutral RPC library that, among other things, supports JSON-RPC and zmq.
upload_time2023-07-26 14:35:02
maintainerLeo Noordergraaf
docs_urlNone
authorMarc Brinkmann
requires_python
licenseMIT
keywords json rpc json-rpc jsonrpc 0mq zmq zeromq
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            tinyrpc: A small and modular way of handling web-related RPC
============================================================

.. image:: https://readthedocs.org/projects/tinyrpc/badge/?version=latest
    :target: https://tinyrpc.readthedocs.io/en/latest
.. image:: https://github.com/mbr/tinyrpc/actions/workflows/python-tox.yml/badge.svg
    :target: https://github.com/mbr/tinyrpc/actions/workflows/python-tox.yml
.. image:: https://badge.fury.io/py/tinyrpc.svg
    :target: https://pypi.org/project/tinyrpc/

Note
----

Tinyrpc has been revised.

The current version will support Python3 only.
Have a look at the 0.9.x version if you need Python2 support.
Python2 support will be dropped completely when Python2 retires,
somewhere in 2020.

Motivation
----------

As of this writing (in Jan 2013) there are a few jsonrpc_ libraries already out
there on PyPI_, most of them handling one specific use case (e.g. json via
WSGI, using Twisted, or TCP-sockets).

None of the libraries, however, makes it easy to reuse the jsonrpc_-parsing bits
and substitute a different transport (i.e. going from json_ via TCP_ to an
implementation using WebSockets_ or 0mq_).

In the end, all these libraries have their own dispatching interfaces and a
custom implementation of handling jsonrpc_.  Today (march 2019) that hasn't changed.

``tinyrpc`` aims to do better by dividing the problem into cleanly
interchangeable parts that allow easy addition of new transport methods, RPC
protocols or dispatchers.

Example:

To create a server process receiving and handling JSONRPC requests do:

.. code-block:: python

    import gevent
    import gevent.pywsgi
    import gevent.queue
    from tinyrpc.protocols.jsonrpc import JSONRPCProtocol
    from tinyrpc.transports.wsgi import WsgiServerTransport
    from tinyrpc.server.gevent import RPCServerGreenlets
    from tinyrpc.dispatch import RPCDispatcher

    dispatcher = RPCDispatcher()
    transport = WsgiServerTransport(queue_class=gevent.queue.Queue)

    # start wsgi server as a background-greenlet
    wsgi_server = gevent.pywsgi.WSGIServer(('127.0.0.1', 5000), transport.handle)
    gevent.spawn(wsgi_server.serve_forever)

    rpc_server = RPCServerGreenlets(transport, JSONRPCProtocol(), dispatcher)

    @dispatcher.public
    def reverse_string(s):
        return s[::-1]

    # in the main greenlet, run our rpc_server
    rpc_server.serve_forever()

The corresponding client code looks like:

.. code-block:: python

    from tinyrpc.protocols.jsonrpc import JSONRPCProtocol
    from tinyrpc.transports.http import HttpPostClientTransport
    from tinyrpc import RPCClient

    rpc_client = RPCClient(
        JSONRPCProtocol(),
        HttpPostClientTransport('http://127.0.0.1:5000/'))

    remote_server = rpc_client.get_proxy()

    # call a method called 'reverse_string' with a single string argument
    result = remote_server.reverse_string('Hello, World!')

    print("Server answered:", result)

Documentation
-------------

You'll quickly find that ``tinyrpc`` has more documentation and tests than core
code, hence the name. See the documentation at
<https://tinyrpc.readthedocs.org> for more details, especially the
Structure-section to get a birds-eye view.

Installation
------------

.. code-block:: sh

   pip install tinyrpc

will install ``tinyrpc`` with its default dependencies.

Optional dependencies
---------------------

Depending on the protocols and transports you want to use additional dependencies
are required. You can instruct pip to install these dependencies by specifying
extras to the basic install command.

.. code-block:: sh

   pip install tinyrpc[httpclient, wsgi]

will install ``tinyrpc`` with dependencies for the httpclient and wsgi transports.

Available extras are:

+------------+-------------------------------------------------------+
| Option     |  Needed to use objects of class                       |
+============+=======================================================+
| gevent     | optional in RPCClient, required by RPCServerGreenlets |
+------------+-------------------------------------------------------+
| httpclient | HttpPostClientTransport, HttpWebSocketClientTransport |
+------------+-------------------------------------------------------+
| msgpack    | implements MSGPACKRPCProtocol                         |
+------------+-------------------------------------------------------+
| jsonext    | optional in JSONRPCProtocol                           |
+------------+-------------------------------------------------------+
| rabbitmq   | RabbitMQServerTransport, RabbitMQClientTransport      |
+------------+-------------------------------------------------------+
| websocket  | WSServerTransport                                     |
+------------+-------------------------------------------------------+
| wsgi       | WsgiServerTransport                                   |
+------------+-------------------------------------------------------+
| zmq        | ZmqServerTransport, ZmqClientTransport                |
+------------+-------------------------------------------------------+

New in version 1.1.0
--------------------

Tinyrpc supports RabbitMQ has transport medium.

New in version 1.0.4
--------------------

Tinyrpc now supports the MSGPACK RPC protocol in addition to JSON-RPC.


.. _jsonrpc: http://www.jsonrpc.org/
.. _PyPI: http://pypi.python.org
.. _json: http://www.json.org/
.. _TCP: http://en.wikipedia.org/wiki/Transmission_Control_Protocol
.. _WebSockets: http://en.wikipedia.org/wiki/WebSocket
.. _0mq: http://www.zeromq.org/

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/mbr/tinyrpc",
    "name": "tinyrpc",
    "maintainer": "Leo Noordergraaf",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "leo@noordergraaf.net",
    "keywords": "json rpc json-rpc jsonrpc 0mq zmq zeromq",
    "author": "Marc Brinkmann",
    "author_email": "git@marcbrinkmann.de",
    "download_url": "https://files.pythonhosted.org/packages/6a/31/b0d0403cafda7965fab0741bcb7c63b26eab7fcfb605d4ece31a6f7b034d/tinyrpc-1.1.7.tar.gz",
    "platform": null,
    "description": "tinyrpc: A small and modular way of handling web-related RPC\n============================================================\n\n.. image:: https://readthedocs.org/projects/tinyrpc/badge/?version=latest\n    :target: https://tinyrpc.readthedocs.io/en/latest\n.. image:: https://github.com/mbr/tinyrpc/actions/workflows/python-tox.yml/badge.svg\n    :target: https://github.com/mbr/tinyrpc/actions/workflows/python-tox.yml\n.. image:: https://badge.fury.io/py/tinyrpc.svg\n    :target: https://pypi.org/project/tinyrpc/\n\nNote\n----\n\nTinyrpc has been revised.\n\nThe current version will support Python3 only.\nHave a look at the 0.9.x version if you need Python2 support.\nPython2 support will be dropped completely when Python2 retires,\nsomewhere in 2020.\n\nMotivation\n----------\n\nAs of this writing (in Jan 2013) there are a few jsonrpc_ libraries already out\nthere on PyPI_, most of them handling one specific use case (e.g. json via\nWSGI, using Twisted, or TCP-sockets).\n\nNone of the libraries, however, makes it easy to reuse the jsonrpc_-parsing bits\nand substitute a different transport (i.e. going from json_ via TCP_ to an\nimplementation using WebSockets_ or 0mq_).\n\nIn the end, all these libraries have their own dispatching interfaces and a\ncustom implementation of handling jsonrpc_.  Today (march 2019) that hasn't changed.\n\n``tinyrpc`` aims to do better by dividing the problem into cleanly\ninterchangeable parts that allow easy addition of new transport methods, RPC\nprotocols or dispatchers.\n\nExample:\n\nTo create a server process receiving and handling JSONRPC requests do:\n\n.. code-block:: python\n\n    import gevent\n    import gevent.pywsgi\n    import gevent.queue\n    from tinyrpc.protocols.jsonrpc import JSONRPCProtocol\n    from tinyrpc.transports.wsgi import WsgiServerTransport\n    from tinyrpc.server.gevent import RPCServerGreenlets\n    from tinyrpc.dispatch import RPCDispatcher\n\n    dispatcher = RPCDispatcher()\n    transport = WsgiServerTransport(queue_class=gevent.queue.Queue)\n\n    # start wsgi server as a background-greenlet\n    wsgi_server = gevent.pywsgi.WSGIServer(('127.0.0.1', 5000), transport.handle)\n    gevent.spawn(wsgi_server.serve_forever)\n\n    rpc_server = RPCServerGreenlets(transport, JSONRPCProtocol(), dispatcher)\n\n    @dispatcher.public\n    def reverse_string(s):\n        return s[::-1]\n\n    # in the main greenlet, run our rpc_server\n    rpc_server.serve_forever()\n\nThe corresponding client code looks like:\n\n.. code-block:: python\n\n    from tinyrpc.protocols.jsonrpc import JSONRPCProtocol\n    from tinyrpc.transports.http import HttpPostClientTransport\n    from tinyrpc import RPCClient\n\n    rpc_client = RPCClient(\n        JSONRPCProtocol(),\n        HttpPostClientTransport('http://127.0.0.1:5000/'))\n\n    remote_server = rpc_client.get_proxy()\n\n    # call a method called 'reverse_string' with a single string argument\n    result = remote_server.reverse_string('Hello, World!')\n\n    print(\"Server answered:\", result)\n\nDocumentation\n-------------\n\nYou'll quickly find that ``tinyrpc`` has more documentation and tests than core\ncode, hence the name. See the documentation at\n<https://tinyrpc.readthedocs.org> for more details, especially the\nStructure-section to get a birds-eye view.\n\nInstallation\n------------\n\n.. code-block:: sh\n\n   pip install tinyrpc\n\nwill install ``tinyrpc`` with its default dependencies.\n\nOptional dependencies\n---------------------\n\nDepending on the protocols and transports you want to use additional dependencies\nare required. You can instruct pip to install these dependencies by specifying\nextras to the basic install command.\n\n.. code-block:: sh\n\n   pip install tinyrpc[httpclient, wsgi]\n\nwill install ``tinyrpc`` with dependencies for the httpclient and wsgi transports.\n\nAvailable extras are:\n\n+------------+-------------------------------------------------------+\n| Option     |  Needed to use objects of class                       |\n+============+=======================================================+\n| gevent     | optional in RPCClient, required by RPCServerGreenlets |\n+------------+-------------------------------------------------------+\n| httpclient | HttpPostClientTransport, HttpWebSocketClientTransport |\n+------------+-------------------------------------------------------+\n| msgpack    | implements MSGPACKRPCProtocol                         |\n+------------+-------------------------------------------------------+\n| jsonext    | optional in JSONRPCProtocol                           |\n+------------+-------------------------------------------------------+\n| rabbitmq   | RabbitMQServerTransport, RabbitMQClientTransport      |\n+------------+-------------------------------------------------------+\n| websocket  | WSServerTransport                                     |\n+------------+-------------------------------------------------------+\n| wsgi       | WsgiServerTransport                                   |\n+------------+-------------------------------------------------------+\n| zmq        | ZmqServerTransport, ZmqClientTransport                |\n+------------+-------------------------------------------------------+\n\nNew in version 1.1.0\n--------------------\n\nTinyrpc supports RabbitMQ has transport medium.\n\nNew in version 1.0.4\n--------------------\n\nTinyrpc now supports the MSGPACK RPC protocol in addition to JSON-RPC.\n\n\n.. _jsonrpc: http://www.jsonrpc.org/\n.. _PyPI: http://pypi.python.org\n.. _json: http://www.json.org/\n.. _TCP: http://en.wikipedia.org/wiki/Transmission_Control_Protocol\n.. _WebSockets: http://en.wikipedia.org/wiki/WebSocket\n.. _0mq: http://www.zeromq.org/\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A small, modular, transport and protocol neutral RPC library that, among other things, supports JSON-RPC and zmq.",
    "version": "1.1.7",
    "project_urls": {
        "Homepage": "http://github.com/mbr/tinyrpc"
    },
    "split_keywords": [
        "json",
        "rpc",
        "json-rpc",
        "jsonrpc",
        "0mq",
        "zmq",
        "zeromq"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "22a0ca9f00c05633e7c2d8f84d4b6ed2ec4640a19802974a3218c9ba3239b543",
                "md5": "5da337be4c3328e4095c1e7a78df3476",
                "sha256": "59f67cd03d42c5d0d2471dd75ac7f1470f53665e92cdba02eecd13ea27cdec70"
            },
            "downloads": -1,
            "filename": "tinyrpc-1.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5da337be4c3328e4095c1e7a78df3476",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 52292,
            "upload_time": "2023-07-26T14:35:00",
            "upload_time_iso_8601": "2023-07-26T14:35:00.335643Z",
            "url": "https://files.pythonhosted.org/packages/22/a0/ca9f00c05633e7c2d8f84d4b6ed2ec4640a19802974a3218c9ba3239b543/tinyrpc-1.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6a31b0d0403cafda7965fab0741bcb7c63b26eab7fcfb605d4ece31a6f7b034d",
                "md5": "b5079a23bbd8c41a33fe15c7486acf3e",
                "sha256": "15a8f41838e7b8be274467de59ad5c571e4cb5a2fe93bc2940b1d103bce4c6e5"
            },
            "downloads": -1,
            "filename": "tinyrpc-1.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "b5079a23bbd8c41a33fe15c7486acf3e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 40178,
            "upload_time": "2023-07-26T14:35:02",
            "upload_time_iso_8601": "2023-07-26T14:35:02.371108Z",
            "url": "https://files.pythonhosted.org/packages/6a/31/b0d0403cafda7965fab0741bcb7c63b26eab7fcfb605d4ece31a6f7b034d/tinyrpc-1.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-26 14:35:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mbr",
    "github_project": "tinyrpc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "tinyrpc"
}
        
Elapsed time: 2.56696s