forked from p15670423/monkey
Common: Rename IslandEventTopics -> IslandEventTopic
This commit is contained in:
parent
c9500cd04f
commit
4219b6cbd4
|
@ -1,4 +1,4 @@
|
||||||
from .types import AgentEventSubscriber
|
from .types import AgentEventSubscriber
|
||||||
from .i_agent_event_queue import IAgentEventQueue
|
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
|
from .pypubsub_agent_event_queue import PyPubSubAgentEventQueue
|
||||||
|
|
|
@ -3,7 +3,7 @@ from enum import Enum
|
||||||
from typing import Any, Callable
|
from typing import Any, Callable
|
||||||
|
|
||||||
|
|
||||||
class IslandEventTopics(Enum):
|
class IslandEventTopic(Enum):
|
||||||
AGENT_CONNECTED = "agent_connected"
|
AGENT_CONNECTED = "agent_connected"
|
||||||
CLEAR_SIMULATION_DATA = "clear_simulation_data"
|
CLEAR_SIMULATION_DATA = "clear_simulation_data"
|
||||||
RESET_AGENT_CONFIGURATION = "reset_agent_configuration"
|
RESET_AGENT_CONFIGURATION = "reset_agent_configuration"
|
||||||
|
@ -15,7 +15,7 @@ class IIslandEventQueue(ABC):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
Subscribes a subscriber to the specified event topic
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class IIslandEventQueue(ABC):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@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
|
Publishes an event topic with the given data
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ from typing import Any, Callable
|
||||||
|
|
||||||
from pubsub.core import Publisher
|
from pubsub.core import Publisher
|
||||||
|
|
||||||
from . import IIslandEventQueue, IslandEventTopics
|
from . import IIslandEventQueue, IslandEventTopic
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ class PyPubSubIslandEventQueue(IIslandEventQueue):
|
||||||
self._pypubsub_publisher = pypubsub_publisher
|
self._pypubsub_publisher = pypubsub_publisher
|
||||||
self._refs = []
|
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
|
topic_value = topic.value # needs to be a string for pypubsub
|
||||||
try:
|
try:
|
||||||
subscriber_name = subscriber.__name__
|
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.
|
# scope. Adding subscribers to self._refs prevents them from ever going out of scope.
|
||||||
self._refs.append(subscriber)
|
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
|
topic_value = topic.value # needs to be a string for pypubsub
|
||||||
|
|
||||||
logger.debug(f"Publishing {topic_value} event")
|
logger.debug(f"Publishing {topic_value} event")
|
||||||
|
|
Loading…
Reference in New Issue