Skip to main content

Configuration driven object/HERO starter

Project description

BOSS Object Starter Service (BOSS)

BOSS is a service that instantiates Python objects as HEROs based on a JSON configuration. The configuration can be read from a file, a URL (e.g. from a CouchDB), or from an environment variable. Essentially, BOSS allows you to quickly wrap your arbitrary Python object as a HERO and to run it.

:open_book: Below is a quick walkthrough of the basic functionalities. You find the full documentation here.

As an example, let's take an object available in the Python standard library, the FTP class from the ftplib module. To make BOSS create an object of the class FTP, we need the following configuration:

{
     "_id": "test-json-ftp",
     "classname": "ftplib.FTP",
     "arguments": {
          "host": "ftp.us.debian.org"
     }
}
python -m boss.starter -u file:///absolute/path/to/ftp.json

Now our object is available in the default realm of our HEROS network. It can be viewed with any HEROObserver. For a graphical view, use HERO-Monitor.

Exposing the BOSS instance itself

To expose the BOSS instance as a HERO, use the --expose command line flag:

python -m boss.starter --expose -u file:///absolute/path/to/ftp.json

When the BOSS instance is exposed, HEROs can be dynamically added and removed by the calling the add_hero(config: dict) and remove_hero(name: str) methods. This allows to run BOSS without any initial configuration and manage the running HEROs from a remote service.

By default, the instance receives a unique name consisting of the hostname and a UUID. To change the name, use the --name argument:

python -m boss.starter --expose --name my_test_boss -u file:///absolute/path/to/ftp.json

Using the asyncio main loop

BOSS starts a asyncio loop that the started objects can use. If your object expects to get the loop object in the constructor you can define attach it to the boss loop through the magic string "@_boss_loop" as in the following example:

{
  "_id": "statemachine",
  "classname": "herostools.actor.statemachine.HERODatasourceStateMachine",
  "arguments": {
    "loop": "@_boss_loop",
    "http_port": 9090,
    "bind_address": "localhost",
    "labels": {"system": "heros"}
  }
}

Docker

A convenient way to deploy BOSS is inside of a Docker container. You can find pre-built containers images in our Docker registry.

You can also build the BOSS Docker image yourself from the Dockerfile in the repository:

docker build -t atomiq/boss .

A BOSS Docker service can be started with the following compose file

version: '2'

services:
  httpclient:
    image: registry.gitlab.com/atomiq-project/boss:latest
    restart: always
    network_mode: host
    environment:
     - |
       BOSS1=
       {
        "_id": "docker-env-ftp",
           "classname": "ftplib.FTP",
           "arguments": {
                "host": "ftp.us.debian.org"
           }
       }
    command: python -m boss.starter -e BOSS1

Additionally, also specifying a file or URL is possible, such that (mounted) JSON files in the Docker container or web URLs can be used as configuration sources. Note that the -e and -u options can be specified multiple times to define several objects that should be instantiated by the BOSS.

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

heros_boss-0.6.5.tar.gz (268.3 kB view details)

Uploaded Source

Built Distribution

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

heros_boss-0.6.5-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file heros_boss-0.6.5.tar.gz.

File metadata

  • Download URL: heros_boss-0.6.5.tar.gz
  • Upload date:
  • Size: 268.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for heros_boss-0.6.5.tar.gz
Algorithm Hash digest
SHA256 4e23a17985624df1dd375e478e6c2d1d1bf3ddfb865c898ce8cc2e713b5fb1fb
MD5 98289d2d6fd3a7c3c2ab95f69fbcc775
BLAKE2b-256 1b6d91a61395ee3dd96bcaa190559af00f086537a7a81496cb94215ec6ef6352

See more details on using hashes here.

File details

Details for the file heros_boss-0.6.5-py3-none-any.whl.

File metadata

  • Download URL: heros_boss-0.6.5-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for heros_boss-0.6.5-py3-none-any.whl
Algorithm Hash digest
SHA256 dead566ad3ad72d685e840d34270ebf8aa8f4219bc7d663f7dec059ad0930480
MD5 65dda7abed235cc711d740514450a4e1
BLAKE2b-256 8501d572a9a83237a60a0499c9f59b794016eb6459a8923fe1a69149d1c17e57

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