asyncactor


Nameasyncactor JSON
Version 0.24.0 PyPI version JSON
download
home_pagehttps://github.com/smurfix/asyncactor
SummaryAsync decentralized actor
upload_time2023-05-17 15:24:27
maintainerMatthias Urlichs
docs_urlNone
authorMatthias Urlichs
requires_python>=3.7
licenseGPL3
keywords serf mqtt orchestration service discovery anyio
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage
            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": "https://github.com/smurfix/asyncactor",
    "name": "asyncactor",
    "maintainer": "Matthias Urlichs",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "matthias@urlichs.de",
    "keywords": "Serf,MQTT,orchestration,service discovery,anyio",
    "author": "Matthias Urlichs",
    "author_email": "matthias@urlichs.de",
    "download_url": "https://files.pythonhosted.org/packages/b9/44/c6a357fc43d5e6bfbb837af36ceb453bf96d66d58b1e5dd728138419ab56/asyncactor-0.24.0.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": "GPL3",
    "summary": "Async decentralized actor",
    "version": "0.24.0",
    "project_urls": {
        "Homepage": "https://github.com/smurfix/asyncactor"
    },
    "split_keywords": [
        "serf",
        "mqtt",
        "orchestration",
        "service discovery",
        "anyio"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "08c8dac1ac2a354621b2bedca349d4604a6c91b6aeee846ffc242fa3e7516ce1",
                "md5": "bdb93bee352567af0240c12478aae399",
                "sha256": "a646d2f0288f932d8cd003dc1f28f7e0491e8ac3d401320b8f19032f7552be6e"
            },
            "downloads": -1,
            "filename": "asyncactor-0.24.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bdb93bee352567af0240c12478aae399",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 24957,
            "upload_time": "2023-05-17T15:24:25",
            "upload_time_iso_8601": "2023-05-17T15:24:25.916766Z",
            "url": "https://files.pythonhosted.org/packages/08/c8/dac1ac2a354621b2bedca349d4604a6c91b6aeee846ffc242fa3e7516ce1/asyncactor-0.24.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b944c6a357fc43d5e6bfbb837af36ceb453bf96d66d58b1e5dd728138419ab56",
                "md5": "b59a4c99a6044938d30c7d467421d053",
                "sha256": "b8f3825e5923a69b48be300dea1efbdffc8f6ad17676523b786f861588594b67"
            },
            "downloads": -1,
            "filename": "asyncactor-0.24.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b59a4c99a6044938d30c7d467421d053",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 32615,
            "upload_time": "2023-05-17T15:24:27",
            "upload_time_iso_8601": "2023-05-17T15:24:27.720540Z",
            "url": "https://files.pythonhosted.org/packages/b9/44/c6a357fc43d5e6bfbb837af36ceb453bf96d66d58b1e5dd728138419ab56/asyncactor-0.24.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-17 15:24:27",
    "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"
}
        
Elapsed time: 0.08869s