asyncactor
==========
AsyncActor is an async Python module that aids in service discovery and
"somewhat-leader" election in a heterogenous, sometimes-disconnected
network.
AsyncActor can run on top of any reliable broadcast channel.
This version includes back-ends for Serf and MQTT.
AsyncActor sends as few packets as possible, thus is well-suited for
IoT-related applications with many stations but limited bandwidth.
Theory of operation
+++++++++++++++++++
Assume that you have a non-lossy network with a bounded latency (let's
assume one second). Assume further that you'd like to know within ten
seconds whether your node is still online.
AsyncActor sends one beacon message every seven to nine seconds. The message
includes a list of N previous hosts that have transmitted the beacon; the
host that's last in this list will be the next transmitter.
The time slot starting at the seven-second mark is used for random hosts
which would like to enter the beacon sending business. This is somewhat
likely if the list of hosts is currently smaller than N. The slot at eight
seconds is used for the hosts at the end of the list; the last host will
send first, but if its beacon is not seen then the next-to-last will send
its message, and so on.
The time slot at nine seconds is used for last-resort messages, i.e. any
participating host can and will send its beacon message.
Collisions are resolved at the ten-second mark, i.e. the list of messages
is ordered deterministically: the winner will announce to its clients that
a new slot has started and whether all N host slots are filled.
It uses `anyio <https://github.com/agronholm/anyio>` as its underlying
async framework.
.. image:: https://badge.fury.io/py/asyncactor.svg
:alt: PyPI latest version badge
:target: https://pypi.python.org/pypi/asyncactor
.. image:: https://coveralls.io/repos/smurfix/asyncactor/badge.png?branch=master
:alt: Code coverage badge
:target: https://coveralls.io/r/smurfix/asyncactor?branch=master
Installation
------------
AsyncActor requires a back-end, i.e. either a running Serf agent or a MQTT
broker.
To install AsyncActor, run the following command:
.. code-block:: bash
$ pip install asyncactor
or alternatively (you really should be using pip though):
.. code-block:: bash
$ easy_install asyncactor
or from source:
.. code-block:: bash
$ python setup.py install
Getting Started
---------------
These examples require a running async loop.
`Trio <https://github.com/python-trio/trio>` is recommended, though
``asyncio`` works too.
.. code-block:: python
from asyncactor import client as actor
from somewhere import some_transport
async with some_transport.connect('localhost') as t:
async with actor(t, prefix=('actor','test')) as client:
async for client.events as m:
print(m)
Development
------------
You can run the tests using the following commands:
.. code-block:: bash
$ serf agent & # start serf agent
$ mosquitto
$ python3 -mpytest tests
Raw data
{
"_id": null,
"home_page": null,
"name": "asyncactor",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "MQTT, orchestration, service discovery, anyio",
"author": null,
"author_email": "Matthias Urlichs <matthias@urlichs.de>",
"download_url": "https://files.pythonhosted.org/packages/36/e2/7c99606f9acb139e9fe6da70e5cdd4d3caf8f8929cae6753f945d0e812f1/asyncactor-0.25.3.tar.gz",
"platform": null,
"description": "asyncactor\n==========\n\nAsyncActor is an async Python module that aids in service discovery and\n\"somewhat-leader\" election in a heterogenous, sometimes-disconnected\nnetwork.\n\nAsyncActor can run on top of any reliable broadcast channel.\nThis version includes back-ends for Serf and MQTT.\n\nAsyncActor sends as few packets as possible, thus is well-suited for\nIoT-related applications with many stations but limited bandwidth.\n\nTheory of operation\n+++++++++++++++++++\n\nAssume that you have a non-lossy network with a bounded latency (let's\nassume one second). Assume further that you'd like to know within ten\nseconds whether your node is still online.\n\nAsyncActor sends one beacon message every seven to nine seconds. The message\nincludes a list of N previous hosts that have transmitted the beacon; the\nhost that's last in this list will be the next transmitter.\n\nThe time slot starting at the seven-second mark is used for random hosts\nwhich would like to enter the beacon sending business. This is somewhat\nlikely if the list of hosts is currently smaller than N. The slot at eight\nseconds is used for the hosts at the end of the list; the last host will\nsend first, but if its beacon is not seen then the next-to-last will send\nits message, and so on.\n\nThe time slot at nine seconds is used for last-resort messages, i.e. any\nparticipating host can and will send its beacon message.\n\nCollisions are resolved at the ten-second mark, i.e. the list of messages\nis ordered deterministically: the winner will announce to its clients that\na new slot has started and whether all N host slots are filled.\n\nIt uses `anyio <https://github.com/agronholm/anyio>` as its underlying\nasync framework.\n\n.. image:: https://badge.fury.io/py/asyncactor.svg\n :alt: PyPI latest version badge\n :target: https://pypi.python.org/pypi/asyncactor\n.. image:: https://coveralls.io/repos/smurfix/asyncactor/badge.png?branch=master\n :alt: Code coverage badge\n :target: https://coveralls.io/r/smurfix/asyncactor?branch=master\n\nInstallation\n------------\n\nAsyncActor requires a back-end, i.e. either a running Serf agent or a MQTT\nbroker.\n\nTo install AsyncActor, run the following command:\n\n.. code-block:: bash\n\n $ pip install asyncactor\n\nor alternatively (you really should be using pip though):\n\n.. code-block:: bash\n\n $ easy_install asyncactor\n\nor from source:\n\n.. code-block:: bash\n\n $ python setup.py install\n\nGetting Started\n---------------\n\nThese examples require a running async loop.\n`Trio <https://github.com/python-trio/trio>` is recommended, though\n``asyncio`` works too.\n\n.. code-block:: python\n\n from asyncactor import client as actor\n from somewhere import some_transport\n\n async with some_transport.connect('localhost') as t:\n async with actor(t, prefix=('actor','test')) as client:\n async for client.events as m:\n print(m)\n\nDevelopment\n------------\n\nYou can run the tests using the following commands:\n\n.. code-block:: bash\n\n $ serf agent & # start serf agent\n $ mosquitto \n $ python3 -mpytest tests\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Async decentralized actor",
"version": "0.25.3",
"project_urls": {
"homepage": "https://github.com/smurfix/asyncactor",
"repository": "https://github.com/smurfix/asyncactor.git"
},
"split_keywords": [
"mqtt",
" orchestration",
" service discovery",
" anyio"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0c1d5e3dfa20f23ff0f596ece05fc151922078aa99402615bd0cde2cfaf68555",
"md5": "ed3a6894e6be42994be12d850ea1bb88",
"sha256": "b7d7c38fec95d2ce494b8852867c53fdd3e6f6fa74df20c820c466a77943aeed"
},
"downloads": -1,
"filename": "asyncactor-0.25.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ed3a6894e6be42994be12d850ea1bb88",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 21282,
"upload_time": "2024-11-24T15:12:45",
"upload_time_iso_8601": "2024-11-24T15:12:45.638008Z",
"url": "https://files.pythonhosted.org/packages/0c/1d/5e3dfa20f23ff0f596ece05fc151922078aa99402615bd0cde2cfaf68555/asyncactor-0.25.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "36e27c99606f9acb139e9fe6da70e5cdd4d3caf8f8929cae6753f945d0e812f1",
"md5": "25b7846eb84d0b7c6be43a258150fb4a",
"sha256": "c49ad0433a09eaa5d11c9b038c3e5e7ef82d16159f700a444ef2d08ad865934e"
},
"downloads": -1,
"filename": "asyncactor-0.25.3.tar.gz",
"has_sig": false,
"md5_digest": "25b7846eb84d0b7c6be43a258150fb4a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 34584,
"upload_time": "2024-11-24T15:12:47",
"upload_time_iso_8601": "2024-11-24T15:12:47.540166Z",
"url": "https://files.pythonhosted.org/packages/36/e2/7c99606f9acb139e9fe6da70e5cdd4d3caf8f8929cae6753f945d0e812f1/asyncactor-0.25.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-24 15:12:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "smurfix",
"github_project": "asyncactor",
"travis_ci": true,
"coveralls": true,
"github_actions": false,
"tox": true,
"lcname": "asyncactor"
}