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.8.0+.
.. 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": null,
"docs_url": null,
"requires_python": "<4.0.0,>=3.8.0",
"maintainer_email": null,
"keywords": "network, protocol, communication",
"author": "LW016",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/32/38/3204165597cc0cf2982026557fcb89b2f0e54c707be4bcbf791084fe5e9d/sayd-1.2.9.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.8.0+.\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\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "A performant asynchronous communication protocol in pure Python.",
"version": "1.2.9",
"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": "53885684a5773757723cb79cd2c274f4c82e0c4f60ea5f84f887eea1588e50dd",
"md5": "8121d58776c169239b8705b8fb8c049e",
"sha256": "72955e1e104701c59970cceeb969754a4923eb93c3a815305a041738582a74f8"
},
"downloads": -1,
"filename": "sayd-1.2.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8121d58776c169239b8705b8fb8c049e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0.0,>=3.8.0",
"size": 17012,
"upload_time": "2024-04-28T22:15:35",
"upload_time_iso_8601": "2024-04-28T22:15:35.129661Z",
"url": "https://files.pythonhosted.org/packages/53/88/5684a5773757723cb79cd2c274f4c82e0c4f60ea5f84f887eea1588e50dd/sayd-1.2.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "32383204165597cc0cf2982026557fcb89b2f0e54c707be4bcbf791084fe5e9d",
"md5": "cc8e99512bcfd2fdbe4304d67a933b94",
"sha256": "1715263de4cf68b5963f773c18d0aa6c31438410f9b140608fade48ed1c496ca"
},
"downloads": -1,
"filename": "sayd-1.2.9.tar.gz",
"has_sig": false,
"md5_digest": "cc8e99512bcfd2fdbe4304d67a933b94",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0.0,>=3.8.0",
"size": 12968,
"upload_time": "2024-04-28T22:15:36",
"upload_time_iso_8601": "2024-04-28T22:15:36.827552Z",
"url": "https://files.pythonhosted.org/packages/32/38/3204165597cc0cf2982026557fcb89b2f0e54c707be4bcbf791084fe5e9d/sayd-1.2.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-28 22:15:36",
"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"
}