rele icon indicating copy to clipboard operation
rele copied to clipboard

Ignore subscriptions without topic defined

Open adrymyry opened this issue 3 years ago • 1 comments

: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.

adrymyry avatar Sep 10 '21 15:09 adrymyry

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.

antoniobusrod avatar Sep 13 '21 07:09 antoniobusrod

PR discontinued.

jonasae avatar Sep 16 '22 14:09 jonasae