msa.core package

Submodules

msa.core.config_manager module

msa.core.event module

msa.core.event_bus module

class msa.core.event_bus.EventBus(loop)[source]

Bases: object

The event bus is responsible for tracking event queues and pushing new events into the event queues so that the event handlers can wait until a new event is sent to them via their event queue.

fire_event(new_event)[source]

Fires an event to each event handler via its corresponding event queue.

Parameters:new_event (msa.core.event.Event) – A subclass of msa.core.event.Event to propagate to event handlers.
listen(timeout=None)[source]

Listens for a new event to be passed into the event bus queue via EventBus.fire_event.

listen_for_result(event_type, timeout=None)[source]
subscribe(event_type, callback)[source]
unsubscribe(event_type, callback)[source]

msa.core.event_handler module

class msa.core.event_handler.EventHandler(loop: asyncio.events.AbstractEventLoop, event_bus: msa.core.event_bus.EventBus, logger: logging.Logger, config: Optional[Dict[KT, VT]] = None)[source]

Bases: object

The base event handler class, all other event handlers should be a subclass of this type.

Variables:
init()[source]

An optional initialization hook, may be used for executing setup code before all handlers have benn fully started.

schedule() → List[Tuple[str, Callable[[], Coroutine[datetime.datetime, None, None]]]][source]

An optional hook, may be used for scheduling one or more methods/functions to be periodically called..

The expected return value is a list of tuples. Each tuple should be a crontab string, followed by a coroutine that should be executed periodically based on the given crontab.

Invalid crontabs will result in a warning in the log, and the coroutine will not be scheduled.

Returns:
Return type:List[Tuple[str, Callable[[], Coroutine[None]]]]

msa.core.loader module

msa.core.loader.load_builtin_modules()[source]

Loads builtin modules.

msa.core.loader.load_plugin_modules(plugin_module_names)[source]

Loads plugin modules as specified in the configuration file.

Parameters:plugin_module_names (List[str]) – Plugin module names to load. Module names should be fully qualified modules existing in msa.plugins.

msa.core.supervisor module

Module contents

msa.core.get_supervisor() → Supervisor[source]