Skip to main content

No project description provided

Project description

MoBits Module Interface

Library to simplify the creation of modules for the mobits infrastructure.

[!NOTE] This library is still under active development, the API might change. For instance since version 1.0.0 we moved from pika to aio-pika as the underlying RMQ library. Moving from synchronous to asynchronous code is a breaking change, therefore we bumped the major version.

Usage

Install this repository as a dependency of your project to bootstrap the creation process of a module inside the mobits infrastructure.

Example usage

import asyncio
from mobits_module_interface import ModuleInterface, main


class MyInterface(ModuleInterface):
    async def callback(self, message):
      # do something with message
      await self.publish(message)


if __name__ == "__main__":
  asyncio.run(main(MyInterface, broker={'uri': 'amqp://localhost'}))

Dev Stuff

Development

Test Execution

To run the tests simply execute

poetry run pytest [-rpP --cov]

To generate HTML reports run

poetry run coverage html

you can find the generated coverage report in ./coverage_html/

High Level Overview

The ModuleInterface class handles two main tasks

  1. Consume incoming messages from RMQ
  2. Publish outgoing messages to RMQ

The ModuleInterface class provides a run() method to start the consumer process as well as establish a connection-channel for the publisher.

The main entry point for module applications is the main() function. It takes a ModuleInterface class as an argument and starts the run() method. Apart from this, it also simplifies the configuration process of the underlying module.

Documentation

Documentation is created using sphinx docs

To check documentation, open docs/build/index.html in your favorite browser (firefox of course)

Create / update documentation (using sphinx)

poetry run sphinx-build -b html docs/source docs/build

Add new file/module to documentation

Using new file models as example:

  1. In docs/build/_sources/index.rst.txt add a file name in TOC e.g. models

    .. toctree::
       :maxdepth: 2
       :caption: Contents:
    
       mobits_module_interface
       module_interface
       state_machine
       models
    
  2. In docs/build/_sources/ create new file with the name of the added module plus .rst.txt extension. For models this would be

    docs/build/_sources/models.rst.txt
    
  3. Depending on the added type (file in existing module, or new module), add content in file

    • length of the ^^^ part must be same length as Headline (Here Dataclass Models)
    • check different content in existing files
    Dataclass Models
    ^^^^^^^^^^^^^^^^
    
    .. automodule:: mobits_module_interface.models
       :members:
       :undoc-members:
       :show-inheritance:
    
  4. Update documentation (see section above)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eb_mi-1.0.0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eb_mi-1.0.0-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file eb_mi-1.0.0.tar.gz.

File metadata

  • Download URL: eb_mi-1.0.0.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for eb_mi-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5a214d83b47d19c15105c19416ec85e77c081364a3355b494f0d6773e65b0abd
MD5 845bde0ade08d8c07502ae1dc1bc6878
BLAKE2b-256 1faf21616c2c43bdd7f3cef1cd19d382d2bc924317bb143ebd1b825a6747e7b3

See more details on using hashes here.

File details

Details for the file eb_mi-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: eb_mi-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for eb_mi-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 36d027a6eb264810c488e50e1c7b48e3f99cb1e67c16c54ba78666256c057496
MD5 42ca341bcd43c654152e431c655784da
BLAKE2b-256 042705464a928c9b426e17366807adba55755a8df230ea4fda1ecdf371d2e577

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page