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.1.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.1-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: eb_mi-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 7bfd1b4a51f9a59354eaa7e9c7e17b1cfd7b72fc25a844428d7bac3cb8d5dc26
MD5 73fc2f09a1b2a175f8250d89a93b50b2
BLAKE2b-256 5efb4df5146330f2e2e8102def323822c0cb26da6b424d31fc017e37bb8e6206

See more details on using hashes here.

File details

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

File metadata

  • Download URL: eb_mi-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 19.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4c148ed69d18921e1715664d88731a1439db8249f307f96ce1d0a8344538850f
MD5 f3e7dce2d3b0d39bda536f70716fb35c
BLAKE2b-256 8e129d18155b9f1a96c139ae9875cbe5f33c819deaa85e677ffd8c35f6ac1e5b

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