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.
-
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: - loop (asyncio.AbstractEventLoop) – the main event loop.
- event_bus (msa.core.event_bus.EventBus) – an event loop that this handler may attempt to read events out of by awaiting on it.
-
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]]]]