boss.boss - heros-boss 0.6.7 documentation

Skip to content
Back to top
View this page

# boss.boss

## Classes

`BOSS` | Use the communication between two processes via a pipe to implement RPC.
`BOSSRemote` | Use the communication between two processes via a pipe to implement RPC.

## Module Contents

class boss.boss.BOSS(name: str, configs: list, loop: asyncio.AbstractEventLoop, realm: str, remote_pipe=None)

  Bases: `boss.multiprocess.MultiprocessRPC`

  Use the communication between two processes via a pipe to implement RPC.

  In BOSS this is used to communicate between the BOSS object in the main process and the BOSSRemote running in a separate process. This becomes necessary since zenoh/rust/pyO3 does not allow to run in the main process and in dynamically generated processes.

  hero_config_sources: list
  name
  heros: dict
  workers: dict
  _loop
  realm
  _config_from_name(name)
  add_hero_source(parser: collections.abc.Callable[[str], boss.configuration.WorkerConfigurationDocument], target: str)

    Adds a data source to the BOSS from which HERO configurations are loaded.

    Parameters:

      - parser – A function which takes `target` as an argument and returns a `boss.configuration.WorkerConfigurationDocument` dict with the HERO config information.

      - target – Target for the `parser`, for example an URL for `boss.configuration.WorkerConfigurationDocument.parse_url()`

  refresh_hero_sources(auto_start: bool = True)

    Refresh the HERO configuration data from the registered sources, updating existing HEROs, adding new ones, and removing those that are no longer present in the sources. HEROs that were running before are only restarted if their configuration changed. HEROs without configuration changes stay untouched.

    Parameters:

      auto_start – If True, automatically starts a new hero source if its configuration is loaded. Defaults to True. Does not influence the behavior of HEROs that are already registered.

  add_hero(config: boss.configuration.WorkerConfigurationDocument | dict, auto_start: bool = True)

    Start a new HERO and keep it running. Note that the id of the HERO specified in the config must be unique.

    Parameters:

      - config – configuration for the new HERO. If a dict is given, it is converted into a WorkerConfigurationDocument.

      - auto_start – If true the new HERO is immediately started after adding

  start_hero(name)

    Start HERO with given name.

  stop_hero(name: str)
  restart_hero(name: str)
  remove_hero(name: str)
  start_all()
  stop_all()
  status()

class boss.boss.BOSSRemote(*args, **kwargs)

  Bases: `boss.multiprocess.MultiprocessRPC`

  Use the communication between two processes via a pipe to implement RPC.

  In BOSS this is used to communicate between the BOSS object in the main process and the BOSSRemote running in a separate process. This becomes necessary since zenoh/rust/pyO3 does not allow to run in the main process and in dynamically generated processes.

  _hero_config_sources = []
  send_message(message)
  add_hero_source(parser: collections.abc.Callable[[str], boss.configuration.WorkerConfigurationDocument], target: str)
  refresh_hero_sources(auto_start: bool = True)
  add_hero(config: boss.configuration.WorkerConfigurationDocument | dict, auto_start: bool = True)
  start_hero(name)
  start_all()
  stop_hero(name)
  stop_all()
  status()
  property hero_config_sources