Common: Add IIslandEventQueue

This commit is contained in:
Shreya Malviya 2022-09-06 11:44:34 +05:30
parent 9bc4d8c241
commit f4a0b89e87
1 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,37 @@
from abc import ABC, abstractmethod
from enum import Enum, auto
from typing import Any, Callable
class IslandEventTopics(Enum):
AGENT_CONNECTED = auto()
CLEAR_SIMULATION_DATA = auto()
RESET_AGENT_CONFIGURATION = auto()
class IIslandEventQueue(ABC):
"""
Manages subscription and publishing of events in the Island
"""
@abstractmethod
def subscribe(self, topic: IslandEventTopics, subscriber: Callable[..., None]):
"""
Subscribes a subscriber to the specified event topic
:param topic: Event topic to which the subscriber should subscribe
:param subscriber: A subscriber that will receive events
"""
pass
@abstractmethod
def publish(self, topic: IslandEventTopics, event_data: Any = None):
"""
Publishes an event topic with the given data
:param topic: Event topic to publish
:param event_data: Event data to pass to subscribers with the event publish
"""
pass