Metadata-Version: 2.4
Name: jrproto
Version: 0.1.0
Summary: Pure python json-rpc protocol
Home-page: https://github.com/tiagocoutinho/jrproto
Author: Jose Tiago Macara Coutinho
Author-email: coutinhotiago@gmail.com
Project-URL: Bug Tracker, https://github.com/tiagocoutinho/jrproto/issues
Keywords: jsonrpc
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Description-Content-Type: text/markdown
Provides-Extra: orjson
Requires-Dist: orjson<4,>=3.6; extra == "orjson"
Provides-Extra: msgpack
Requires-Dist: msgpack>=1; extra == "msgpack"
Requires-Dist: python-netstring>=0.6; extra == "msgpack"
Provides-Extra: examples
Requires-Dist: click>=7; extra == "examples"
Requires-Dist: msgpack>=1; extra == "examples"
Requires-Dist: python-netstring>=0.6; extra == "examples"
Provides-Extra: test
Requires-Dist: orjson<4,>=3.6; extra == "test"
Requires-Dist: msgpack>=1; extra == "test"
Requires-Dist: python-netstring>=0.6; extra == "test"
Requires-Dist: pytest>=6; extra == "test"
Requires-Dist: pytest-cov>=2; extra == "test"
Requires-Dist: pytest-asyncio>=0.16; extra == "test"
Requires-Dist: flake8>=3.9; extra == "test"
Requires-Dist: tox>=3.24; extra == "test"

# JSON-RPC protocol

Transports:

* local
* pipe
* netstring/TCP
* HTTP/TCP
* 0MQ?


```python
import jrproto


def add(a, b):
    return a + b


async def sub(a, b):
    return a - b


server = jrproto.server.local.LocalServer()
server = jrproto.server.tcp.TCPServer(("", 9999))


server.register(add)
server.register(sub)


client = Client()

assert client.request("add", 9, 5) == 14
assert client.notification("add", 9, 5) is None


assert client.add(9, 5) == 14
```


### Message pipeline

```
        payload          message            response         line
stream ========> unpack ========>  ==> call ========> pack =====> send  [request]
                                   |
                                   | ==> call ---> null                 [notification]
                                   |
                                   | ==> (fill future, callback, etc)   [response]

```

*stream*: a stream of payload events
*payload*: a buffer representing a complete JSON-RPC message (request, notification, response)
*unpack*: translate a buffer into a python dict representing JSON-RPC message
*message*: python dict representing JSON-RPC message
