Cyclotron
A functional and reactive framework for RxPY.
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:
How to use it
The following example is an http echo server:
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.
pip install cyclotron-aiohttp
you can then test it with an http client like curl:
$ curl http://localhost:8080/echo/hello
hello
Install
Cyclotron is available on PyPi and can be installed with pip:
pip install cyclotron
Cyclotron automatically uses 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 |
|---|---|
License
This project is licensed under the MIT License - see the License file for details
Metadata
Release files for cyclotron 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cyclotron-2.0.1.tar.gz | 9.4 kB | Without provenance | Details for cyclotron-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cyclotron-2.0.1-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for cyclotron-2.0.1-py2.py3-none-any.whl |
Total release size: 18.9 kB
Release files / cyclotron-2.0.1.tar.gz
| Download URL | cyclotron-2.0.1.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
939ea8c625ede47175383aada681afe4e967b7f4aba576b6a1e3bfb84e1055a5
|
|
BLAKE2b-256 checksum How to use checksums |
39de8be7c640f27715132499398a4489f9c6a01aa105d9467f5e4ef557da9f01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / cyclotron-2.0.1-py2.py3-none-any.whl
| Download URL | cyclotron-2.0.1-py2.py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
5dac54a26e10791ed7cd1897ad40aee40772dd4db37233497e19d90eea103579
|
|
BLAKE2b-256 checksum How to use checksums |
f19a749fb12f8df30f603a634380b58fe9148651cc9455c0659af115b2a7731f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Security for cyclotron 2.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.