Common: Rename IslandEventTopics -> IslandEventTopic

This commit is contained in:
Shreya Malviya 2022-09-06 13:19:53 +05:30
parent c9500cd04f
commit 4219b6cbd4
3 changed files with 7 additions and 7 deletions

View File

@ -1,4 +1,4 @@
from .types import AgentEventSubscriber
from .i_agent_event_queue import IAgentEventQueue
from .i_island_event_queue import IIslandEventQueue, IslandEventTopics
from .i_island_event_queue import IIslandEventQueue, IslandEventTopic
from .pypubsub_agent_event_queue import PyPubSubAgentEventQueue

View File

@ -3,7 +3,7 @@ from enum import Enum
from typing import Any, Callable
class IslandEventTopics(Enum):
class IslandEventTopic(Enum):
AGENT_CONNECTED = "agent_connected"
CLEAR_SIMULATION_DATA = "clear_simulation_data"
RESET_AGENT_CONFIGURATION = "reset_agent_configuration"
@ -15,7 +15,7 @@ class IIslandEventQueue(ABC):
"""
@abstractmethod
def subscribe(self, topic: IslandEventTopics, subscriber: Callable[..., None]):
def subscribe(self, topic: IslandEventTopic, subscriber: Callable[..., None]):
"""
Subscribes a subscriber to the specified event topic
@ -26,7 +26,7 @@ class IIslandEventQueue(ABC):
pass
@abstractmethod
def publish(self, topic: IslandEventTopics, event_data: Any = None):
def publish(self, topic: IslandEventTopic, event_data: Any = None):
"""
Publishes an event topic with the given data

View File

@ -3,7 +3,7 @@ from typing import Any, Callable
from pubsub.core import Publisher
from . import IIslandEventQueue, IslandEventTopics
from . import IIslandEventQueue, IslandEventTopic
logger = logging.getLogger(__name__)
@ -13,7 +13,7 @@ class PyPubSubIslandEventQueue(IIslandEventQueue):
self._pypubsub_publisher = pypubsub_publisher
self._refs = []
def subscribe(self, topic: IslandEventTopics, subscriber: Callable[..., None]):
def subscribe(self, topic: IslandEventTopic, subscriber: Callable[..., None]):
topic_value = topic.value # needs to be a string for pypubsub
try:
subscriber_name = subscriber.__name__
@ -52,7 +52,7 @@ class PyPubSubIslandEventQueue(IIslandEventQueue):
# scope. Adding subscribers to self._refs prevents them from ever going out of scope.
self._refs.append(subscriber)
def publish(self, topic: IslandEventTopics, event_data: Any = None):
def publish(self, topic: IslandEventTopic, event_data: Any = None):
topic_value = topic.value # needs to be a string for pypubsub
logger.debug(f"Publishing {topic_value} event")