Island: Accept any kwargs in IIslandEventQueue.publish()

This commit is contained in:
Mike Salvatore 2022-09-21 12:53:39 -04:00
parent a76273fa0d
commit b4c8ac7242
2 changed files with 7 additions and 9 deletions

View File

@ -1,6 +1,5 @@
from abc import ABC, abstractmethod
from enum import Enum, auto
from typing import Any
from . import IslandEventSubscriber
@ -29,12 +28,12 @@ class IIslandEventQueue(ABC):
pass
@abstractmethod
def publish(self, topic: IslandEventTopic, event: Any = None):
def publish(self, topic: IslandEventTopic, **kwargs):
"""
Publishes an event topic with the given data
:param topic: Event topic to publish
:param event: Event data to publish
:param **kwargs: Event data to publish
"""
pass

View File

@ -1,5 +1,4 @@
import logging
from typing import Any
from pubsub.core import Publisher
@ -18,11 +17,11 @@ class PyPubSubIslandEventQueue(IIslandEventQueue):
topic_name = topic.name # needs to be a string for pypubsub
self._pypubsub_publisher_wrapper.subscribe(topic_name, subscriber)
def publish(self, topic: IslandEventTopic, event: Any = None):
def publish(self, topic: IslandEventTopic, **kwargs):
topic_name = topic.name # needs to be a string for pypubsub
logger.debug(f"Publishing {topic_name} event")
if event is None:
self._pypubsub_publisher_wrapper.publish(topic_name)
else:
self._pypubsub_publisher_wrapper.publish(topic_name, event=event)
# if event is None:
# self._pypubsub_publisher_wrapper.publish(topic_name)
# else:
self._pypubsub_publisher_wrapper.publish(topic_name, **kwargs)