rele
rele copied to clipboard
Ignore subscriptions without topic defined
:tophat: What?
Ignore subscriptions that do not define a topic name.
:thinking: Why?
Autodiscovery support for class-based Subscriptions (https://github.com/mercadona/rele/issues/161) opens the possibility to create generic classes with shared behavior between subclasses.
class GenericClass(Subscription):
topic = None
def __init__(self):
self._func = self.callback_func
super().__init__(self._func, self.topic)
def callback_func(self, data, **kwargs):
return data["type"]
class ClassA(GenericClass):
topic = "topic-for-A-messages"
class ClassB(GenericClass):
topic = "topic-for-B-messages"
GenericClass
is a subclass of Subscription
so it will be loaded in the autodiscovery process. However, it does not seem reasonable since it will not be subscribed to any topic.
What do you think to raise a warning instead of skipping these subscriptions? I think we should be explicit and generic about the content which should be exist in the subs
modules.
PR discontinued.