Motion
Motion is a high-level task dispatch & response framework for Amazon Kinesis. It is built on top of the low-level kinesis-python library and inspired by the task definition of Celery.
Motion is still under heavy development. Things here may change
Usage
Create a Motion object:
from motion import Motion
tasks = Motion(stream_name='my-kinesis-stream')
Responding to tasks
@tasks.respond_to('my-event')
def my_event_handler(payload):
# do something with payload...
Dispatching tasks
# dispatch an event 'my-event' with the specified payload
tasks.dispatch('my-event', {'foo': 'bar'})
Running workers
Marshalling
Events and Payloads are converted into byte streams suitable for transport on a Kinesis stream via the process of Marshalling. Motion ships with a default JSON Marshalling class that simply converts a Python object into its JSON equivalent, wrapped with the event name, but the Marshalling operations can be extended to support any type of serialization that is desired (i.e. protobuf, avro, etc)
To implement a custom Marshal you must satisfy the following method signature:
class MyMarshal(object):
def to_native(self, payload):
# de-serialize payload
return event_name, event_payload
def to_bytes(self, event_name, payload):
# serialize payload
return serialized_payload
Then pass an instance of your marshalling class when you create your Motion instance via the marshal= keyword.
Event names
In the basic example the .respond_to decorator is used with a string, since that's what the default JSON Marshal
returns, but since custom marshalling can return anything for the event_name during the .to_native call then you
can use whatever symbol you choose in the .respond_to decorator.
Metadata
Release files for motion 0.2.0
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 | |
|---|---|---|---|---|
| motion-0.2.0.tar.gz | 7.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| motion-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.9 kB
Release files / motion-0.2.0.tar.gz
| Download URL | motion-0.2.0.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ef37d33e3c839cb90252c63f6d4ad05afb039359c9935f8faa850dce4efad4f
|
|
BLAKE2b-256 checksum How to use checksums |
cdeb01bc2ffc420579fab4910c9938039daeaa962ef2db848aad6089c403a3e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.0
|
Release files / motion-0.2.0-py3-none-any.whl
| Download URL | motion-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4ed068b47952689a31ff4d4d5bb875dc658bc1f425dfe98c0b47af8bff7768e1
|
|
BLAKE2b-256 checksum How to use checksums |
c8c14bc02314697c96000d23addfa6b3e23c553e097adc033a3f8deacdc6de96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.0
|
Security for motion 0.2.0
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.