Sayd
====
*A performant asynchronous communication protocol in pure Python.*
This library was developed with simplicity and performance in mind, with modern practices of Python development.
`Documentation Reference <https://sayd.readthedocs.io>`_
Install
-------
Works on Python 3.7.4+.
.. code-block:: bash
pip install sayd
Development
-----------
You need to have installed `poetry <https://github.com/python-poetry/poetry>`_ for dependencies management (`how to <https://python-poetry.org/docs/#installation>`_).
.. code-block:: bash
git clone https://github.com/lw016/sayd
cd sayd
poetry install
Run tests
^^^^^^^^^
.. code-block:: bash
poetry run tox -e tests
Build docs
^^^^^^^^^^
.. code-block:: bash
poetry run tox -e docs
Features
--------
- Client and server implementations
- Reliable TCP persistent connection
- Auto reconnection *(client)*
- Multiple asynchronous connections *(server)*
- Blacklist of clients *(server)*
- TLS encryption
- Proxy Protocol V2 support *(server)*
- Data transmitted as dictionaries *(json)*
- Broadcast *(server)*
- Remote function callbacks
- Built-in CLI utility to generate self-signed certificates
Roadmap
-------
- Add support to Unix socket
- Implement TLS certificate authentication
CLI
---
The built-in CLI utility (*sayd*) can be used to generate self-signed certificates to encrypt the connection.
.. code-block:: bash
sayd --help
Usage example
-------------
Server
^^^^^^
.. code-block:: python
import logging
import asyncio
from sayd import SaydServer
logging.basicConfig(
format="[%(name)s][%(levelname)s] %(asctime)s - %(message)s",
datefmt="%Y/%m/%d %H:%M:%S"
)
logger = logging.getLogger("SERVER")
logger.setLevel(logging.INFO)
server = SaydServer(logger=logger)
@server.callback("message")
async def msg(address: tuple, instance: str, data: dict) -> dict:
return {"greetings": "Hello from server!"}
async def main() -> None:
await server.start()
while True:
result = await server.call("msg", {"greetings": "Hi!"}) # Broadcast call.
print(result)
await asyncio.sleep(1)
await server.stop()
if __name__ == "__main__":
asyncio.run(main())
Client
^^^^^^
.. code-block:: python
import logging
import asyncio
from sayd import SaydClient
logging.basicConfig(
format="[%(name)s][%(levelname)s] %(asctime)s - %(message)s",
datefmt="%Y/%m/%d %H:%M:%S"
)
logger = logging.getLogger("CLIENT")
logger.setLevel(logging.INFO)
client = SaydClient(logger=logger)
@client.callback("msg")
async def msg(instance: str, data: dict) -> dict:
return {"greetings": "Hello from client!"}
async def main() -> None:
await client.start()
while True:
result = await client.call("message", {"greetings": "Hi!"})
print(result)
await asyncio.sleep(1)
await client.stop()
if __name__ == "__main__":
asyncio.run(main())
Raw data
{
"_id": null,
"home_page": "https://github.com/lw016/sayd",
"name": "sayd",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7.4,<4.0.0",
"maintainer_email": "",
"keywords": "network,protocol,communication",
"author": "LW016",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/fc/88/a204e44269e7ae0176b54829c488fced0ac4dd80735d2e20ebd39a9d58d6/sayd-1.2.8.tar.gz",
"platform": null,
"description": "Sayd\n====\n*A performant asynchronous communication protocol in pure Python.*\n\nThis library was developed with simplicity and performance in mind, with modern practices of Python development.\n\n`Documentation Reference <https://sayd.readthedocs.io>`_\n\n\nInstall\n-------\nWorks on Python 3.7.4+.\n\n.. code-block:: bash\n\n pip install sayd\n\n\nDevelopment\n-----------\nYou need to have installed `poetry <https://github.com/python-poetry/poetry>`_ for dependencies management (`how to <https://python-poetry.org/docs/#installation>`_).\n\n.. code-block:: bash\n\n git clone https://github.com/lw016/sayd\n cd sayd\n poetry install\n\n\nRun tests\n^^^^^^^^^\n.. code-block:: bash\n\n poetry run tox -e tests\n\nBuild docs\n^^^^^^^^^^\n.. code-block:: bash\n\n poetry run tox -e docs\n\n\nFeatures\n--------\n- Client and server implementations\n- Reliable TCP persistent connection\n- Auto reconnection *(client)*\n- Multiple asynchronous connections *(server)*\n- Blacklist of clients *(server)*\n- TLS encryption\n- Proxy Protocol V2 support *(server)*\n- Data transmitted as dictionaries *(json)*\n- Broadcast *(server)*\n- Remote function callbacks\n- Built-in CLI utility to generate self-signed certificates\n\n\nRoadmap\n-------\n- Add support to Unix socket\n- Implement TLS certificate authentication\n\n\nCLI\n---\nThe built-in CLI utility (*sayd*) can be used to generate self-signed certificates to encrypt the connection.\n\n.. code-block:: bash\n\n sayd --help\n\n\nUsage example\n-------------\nServer\n^^^^^^\n.. code-block:: python\n\n import logging\n import asyncio\n\n from sayd import SaydServer\n\n\n logging.basicConfig(\n format=\"[%(name)s][%(levelname)s] %(asctime)s - %(message)s\",\n datefmt=\"%Y/%m/%d %H:%M:%S\"\n )\n\n logger = logging.getLogger(\"SERVER\")\n logger.setLevel(logging.INFO)\n\n\n server = SaydServer(logger=logger)\n\n\n @server.callback(\"message\")\n async def msg(address: tuple, instance: str, data: dict) -> dict:\n return {\"greetings\": \"Hello from server!\"}\n\n\n async def main() -> None:\n await server.start()\n \n \n while True:\n result = await server.call(\"msg\", {\"greetings\": \"Hi!\"}) # Broadcast call.\n print(result)\n\n await asyncio.sleep(1)\n \n \n await server.stop()\n\n\n if __name__ == \"__main__\":\n asyncio.run(main())\n\nClient\n^^^^^^\n.. code-block:: python\n\n import logging\n import asyncio\n\n from sayd import SaydClient\n\n\n logging.basicConfig(\n format=\"[%(name)s][%(levelname)s] %(asctime)s - %(message)s\",\n datefmt=\"%Y/%m/%d %H:%M:%S\"\n )\n\n logger = logging.getLogger(\"CLIENT\")\n logger.setLevel(logging.INFO)\n\n\n client = SaydClient(logger=logger)\n\n\n @client.callback(\"msg\")\n async def msg(instance: str, data: dict) -> dict:\n return {\"greetings\": \"Hello from client!\"}\n\n\n async def main() -> None:\n await client.start()\n\n\n while True:\n result = await client.call(\"message\", {\"greetings\": \"Hi!\"})\n print(result)\n\n await asyncio.sleep(1)\n\n \n await client.stop()\n\n\n if __name__ == \"__main__\":\n asyncio.run(main())\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "A performant asynchronous communication protocol in pure Python.",
"version": "1.2.8",
"project_urls": {
"Homepage": "https://github.com/lw016/sayd",
"Repository": "https://github.com/lw016/sayd"
},
"split_keywords": [
"network",
"protocol",
"communication"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "947f1ca05439a9bfa1a41c21317b77869a7225b632f950cfda3c243fa4b5e598",
"md5": "137451a5539678e8f293353937c15189",
"sha256": "0c05e3cb3d98eb11414e1a41b97a5a88468f5f793b2dc16ea8eabea3cd55850b"
},
"downloads": -1,
"filename": "sayd-1.2.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "137451a5539678e8f293353937c15189",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7.4,<4.0.0",
"size": 16747,
"upload_time": "2024-03-02T18:24:20",
"upload_time_iso_8601": "2024-03-02T18:24:20.792088Z",
"url": "https://files.pythonhosted.org/packages/94/7f/1ca05439a9bfa1a41c21317b77869a7225b632f950cfda3c243fa4b5e598/sayd-1.2.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fc88a204e44269e7ae0176b54829c488fced0ac4dd80735d2e20ebd39a9d58d6",
"md5": "6fb4e87cd61bc9f5225dea043a595b54",
"sha256": "ef0d5411301b2fe9b1d05684fb77cd2c745579c6c88b22ae8e57e0010bf85ee1"
},
"downloads": -1,
"filename": "sayd-1.2.8.tar.gz",
"has_sig": false,
"md5_digest": "6fb4e87cd61bc9f5225dea043a595b54",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7.4,<4.0.0",
"size": 13804,
"upload_time": "2024-03-02T18:24:22",
"upload_time_iso_8601": "2024-03-02T18:24:22.685895Z",
"url": "https://files.pythonhosted.org/packages/fc/88/a204e44269e7ae0176b54829c488fced0ac4dd80735d2e20ebd39a9d58d6/sayd-1.2.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-02 18:24:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "lw016",
"github_project": "sayd",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "sayd"
}