cyclotron


Namecyclotron JSON
Version 2.0.1 PyPI version JSON
download
home_page
SummaryA reactive stream cycle implementation in python
upload_time2023-02-05 14:40:45
maintainer
docs_urlNone
authorRomain Picard
requires_python>=3.7
licenseCopyright (c) 2018 by Romain Picard Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords reactivex cyclejs
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ===========================
|cyclotron-logo| Cyclotron
===========================

.. |cyclotron-logo| image:: https://github.com/mainro/cyclotron-py/raw/master/docs/asset/cyclotron_logo.png

A functional and reactive framework for `RxPY <https://github.com/ReactiveX/RxPY/>`_.

.. image:: https://github.com/MainRo/cyclotron-py/actions/workflows/ci.yml/badge.svg
    :target: https://github.com/MainRo/cyclotron-py/actions/workflows/ci.yml

.. image:: https://badge.fury.io/py/cyclotron.svg
    :target: https://badge.fury.io/py/cyclotron

.. image:: https://readthedocs.org/projects/cyclotron-py/badge/?version=latest
    :target: https://cyclotron-py.readthedocs.io/en/latest/?badge=latest
    :alt: Documentation Status



----------------------

With Cyclotron, you can structure your RxPY code as many reusable components.
Moreover it naturally encourages to separate pure code and side effects. So a
Cyclotron application is easier to test, maintain, and extend.

Here is the structure of a cyclotron application:

.. figure:: https://github.com/mainro/cyclotron-py/raw/master/docs/asset/cycle.png
    :width: 60%
    :align: center

How to use it
=============

The following example is an http echo server:

.. code:: python

    from collections import namedtuple

    from cyclotron import Component
    from cyclotron.asyncio.runner import run
    import cyclotron_aiohttp.httpd as httpd
    import reactivex as rx
    import reactivex.operators as ops

    EchoSource = namedtuple('EchoSource', ['httpd'])
    EchoSink = namedtuple('EchoSink', ['httpd'])
    EchoDrivers = namedtuple('EchoDrivers', ['httpd'])

    def echo_server(source):
        init = rx.from_([
            httpd.Initialize(),
            httpd.AddRoute(methods=['GET'], path='/echo/{what}', id='echo'),
            httpd.StartServer(host='localhost', port=8080),
        ])

        echo = source.httpd.route.pipe(
            ops.filter(lambda i: i.id == 'echo'),
            ops.flat_map(lambda i: i.request),
            ops.map(lambda i: httpd.Response(
                context=i.context,
                data=i.match_info['what'].encode('utf-8')),
            )
        )

        control = rx.merge(init, echo)
        return EchoSink(httpd=httpd.Sink(control=control))


    def main():
        run(Component(call=echo_server, input=EchoSource),
            EchoDrivers(httpd=httpd.make_driver()))


    if __name__ == '__main__':
        main()

In this application, the echo_server function is a pure function, while the http
server is implemented as a driver. 

.. code::

    pip install cyclotron-aiohttp

you can then test it with an http client like curl:

.. code::

    $ curl http://localhost:8080/echo/hello
    hello
    

Install
========

Cyclotron is available on PyPi and can be installed with pip:

.. code:: console

    pip install cyclotron

Cyclotron automatically uses `uvloop <https://github.com/MagicStack/uvloop>`_
if it is available.

This project is composed of several python packages. Install also the ones that
you use in your application:

====================================================================  =========================
Package                                                               Version
====================================================================  =========================
`cyclotron <https://github.com/mainro/cyclotron-py>`_                 |pypi-cyclotron|
`cyclotron-std <https://github.com/mainro/cyclotron-std>`_            |pypi-cyclotron-std|
`cyclotron-aiohttp <https://github.com/mainro/cyclotron-aiohttp>`_    |pypi-cyclotron-aiohttp|
`cyclotron-aiokafka <https://github.com/mainro/cyclotron-aiokafka>`_  |pypi-cyclotron-aiokafka|
`cyclotron-consul <https://github.com/mainro/cyclotron-consul>`_      |pypi-cyclotron-consul|
====================================================================  =========================

.. |pypi-cyclotron| image:: https://badge.fury.io/py/cyclotron.svg
    :target: https://badge.fury.io/py/cyclotron

.. |pypi-cyclotron-aiohttp| image:: https://badge.fury.io/py/cyclotron-aiohttp.svg
    :target: https://badge.fury.io/py/cyclotron-aiohttp

.. |pypi-cyclotron-std| image:: https://badge.fury.io/py/cyclotron-std.svg
    :target: https://badge.fury.io/py/cyclotron-std

.. |pypi-cyclotron-aiokafka| image:: https://badge.fury.io/py/cyclotron-aiokafka.svg
    :target: https://badge.fury.io/py/cyclotron-aiokafka

.. |pypi-cyclotron-consul| image:: https://badge.fury.io/py/cyclotron-consul.svg
    :target: https://badge.fury.io/py/cyclotron-consul


License
=========

This project is licensed under the MIT License - see the `License
<https://github.com/mainro/cyclotron-py/raw/master/LICENSE.txt>`_ file for
details

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "cyclotron",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "reactivex,cyclejs",
    "author": "Romain Picard",
    "author_email": "romain.picard@oakbits.com",
    "download_url": "https://files.pythonhosted.org/packages/39/de/8be7c640f27715132499398a4489f9c6a01aa105d9467f5e4ef557da9f01/cyclotron-2.0.1.tar.gz",
    "platform": null,
    "description": "===========================\n|cyclotron-logo| Cyclotron\n===========================\n\n.. |cyclotron-logo| image:: https://github.com/mainro/cyclotron-py/raw/master/docs/asset/cyclotron_logo.png\n\nA functional and reactive framework for `RxPY <https://github.com/ReactiveX/RxPY/>`_.\n\n.. image:: https://github.com/MainRo/cyclotron-py/actions/workflows/ci.yml/badge.svg\n    :target: https://github.com/MainRo/cyclotron-py/actions/workflows/ci.yml\n\n.. image:: https://badge.fury.io/py/cyclotron.svg\n    :target: https://badge.fury.io/py/cyclotron\n\n.. image:: https://readthedocs.org/projects/cyclotron-py/badge/?version=latest\n    :target: https://cyclotron-py.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n\n\n\n----------------------\n\nWith Cyclotron, you can structure your RxPY code as many reusable components.\nMoreover it naturally encourages to separate pure code and side effects. So a\nCyclotron application is easier to test, maintain, and extend.\n\nHere is the structure of a cyclotron application:\n\n.. figure:: https://github.com/mainro/cyclotron-py/raw/master/docs/asset/cycle.png\n    :width: 60%\n    :align: center\n\nHow to use it\n=============\n\nThe following example is an http echo server:\n\n.. code:: python\n\n    from collections import namedtuple\n\n    from cyclotron import Component\n    from cyclotron.asyncio.runner import run\n    import cyclotron_aiohttp.httpd as httpd\n    import reactivex as rx\n    import reactivex.operators as ops\n\n    EchoSource = namedtuple('EchoSource', ['httpd'])\n    EchoSink = namedtuple('EchoSink', ['httpd'])\n    EchoDrivers = namedtuple('EchoDrivers', ['httpd'])\n\n    def echo_server(source):\n        init = rx.from_([\n            httpd.Initialize(),\n            httpd.AddRoute(methods=['GET'], path='/echo/{what}', id='echo'),\n            httpd.StartServer(host='localhost', port=8080),\n        ])\n\n        echo = source.httpd.route.pipe(\n            ops.filter(lambda i: i.id == 'echo'),\n            ops.flat_map(lambda i: i.request),\n            ops.map(lambda i: httpd.Response(\n                context=i.context,\n                data=i.match_info['what'].encode('utf-8')),\n            )\n        )\n\n        control = rx.merge(init, echo)\n        return EchoSink(httpd=httpd.Sink(control=control))\n\n\n    def main():\n        run(Component(call=echo_server, input=EchoSource),\n            EchoDrivers(httpd=httpd.make_driver()))\n\n\n    if __name__ == '__main__':\n        main()\n\nIn this application, the echo_server function is a pure function, while the http\nserver is implemented as a driver. \n\n.. code::\n\n    pip install cyclotron-aiohttp\n\nyou can then test it with an http client like curl:\n\n.. code::\n\n    $ curl http://localhost:8080/echo/hello\n    hello\n    \n\nInstall\n========\n\nCyclotron is available on PyPi and can be installed with pip:\n\n.. code:: console\n\n    pip install cyclotron\n\nCyclotron automatically uses `uvloop <https://github.com/MagicStack/uvloop>`_\nif it is available.\n\nThis project is composed of several python packages. Install also the ones that\nyou use in your application:\n\n====================================================================  =========================\nPackage                                                               Version\n====================================================================  =========================\n`cyclotron <https://github.com/mainro/cyclotron-py>`_                 |pypi-cyclotron|\n`cyclotron-std <https://github.com/mainro/cyclotron-std>`_            |pypi-cyclotron-std|\n`cyclotron-aiohttp <https://github.com/mainro/cyclotron-aiohttp>`_    |pypi-cyclotron-aiohttp|\n`cyclotron-aiokafka <https://github.com/mainro/cyclotron-aiokafka>`_  |pypi-cyclotron-aiokafka|\n`cyclotron-consul <https://github.com/mainro/cyclotron-consul>`_      |pypi-cyclotron-consul|\n====================================================================  =========================\n\n.. |pypi-cyclotron| image:: https://badge.fury.io/py/cyclotron.svg\n    :target: https://badge.fury.io/py/cyclotron\n\n.. |pypi-cyclotron-aiohttp| image:: https://badge.fury.io/py/cyclotron-aiohttp.svg\n    :target: https://badge.fury.io/py/cyclotron-aiohttp\n\n.. |pypi-cyclotron-std| image:: https://badge.fury.io/py/cyclotron-std.svg\n    :target: https://badge.fury.io/py/cyclotron-std\n\n.. |pypi-cyclotron-aiokafka| image:: https://badge.fury.io/py/cyclotron-aiokafka.svg\n    :target: https://badge.fury.io/py/cyclotron-aiokafka\n\n.. |pypi-cyclotron-consul| image:: https://badge.fury.io/py/cyclotron-consul.svg\n    :target: https://badge.fury.io/py/cyclotron-consul\n\n\nLicense\n=========\n\nThis project is licensed under the MIT License - see the `License\n<https://github.com/mainro/cyclotron-py/raw/master/LICENSE.txt>`_ file for\ndetails\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2018 by Romain Picard  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A reactive stream cycle implementation in python",
    "version": "2.0.1",
    "split_keywords": [
        "reactivex",
        "cyclejs"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f19a749fb12f8df30f603a634380b58fe9148651cc9455c0659af115b2a7731f",
                "md5": "86d22cc9ca6c1d50cd35e0fe0c025a3c",
                "sha256": "5dac54a26e10791ed7cd1897ad40aee40772dd4db37233497e19d90eea103579"
            },
            "downloads": -1,
            "filename": "cyclotron-2.0.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "86d22cc9ca6c1d50cd35e0fe0c025a3c",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7",
            "size": 9555,
            "upload_time": "2023-02-05T14:40:43",
            "upload_time_iso_8601": "2023-02-05T14:40:43.428967Z",
            "url": "https://files.pythonhosted.org/packages/f1/9a/749fb12f8df30f603a634380b58fe9148651cc9455c0659af115b2a7731f/cyclotron-2.0.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "39de8be7c640f27715132499398a4489f9c6a01aa105d9467f5e4ef557da9f01",
                "md5": "f9a119de43a57769bbbb8c81e31395ba",
                "sha256": "939ea8c625ede47175383aada681afe4e967b7f4aba576b6a1e3bfb84e1055a5"
            },
            "downloads": -1,
            "filename": "cyclotron-2.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "f9a119de43a57769bbbb8c81e31395ba",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 9394,
            "upload_time": "2023-02-05T14:40:45",
            "upload_time_iso_8601": "2023-02-05T14:40:45.118705Z",
            "url": "https://files.pythonhosted.org/packages/39/de/8be7c640f27715132499398a4489f9c6a01aa105d9467f5e4ef557da9f01/cyclotron-2.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-05 14:40:45",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "cyclotron"
}
        
Elapsed time: 0.04197s