SvenO3 commented on code in PR #1126:
URL: https://github.com/apache/streampipes/pull/1126#discussion_r1082357434


##########
streampipes-client-python/streampipes_client/endpoint/endpoint.py:
##########
@@ -209,3 +212,76 @@ def get(self, identifier: str) -> Resource:
         )
 
         return self._container_cls._resource_cls()(**response.json())
+
+
+class MessagingEndpoint(Endpoint):
+    """Abstract implementation of an StreamPipes messaging endpoint.
+    Serves as template for all endpoints used for interacting with the 
StreamPipes messaging layer directly.
+    Therefore, they need to provide the functionality to talk with the broker 
system running in StreamPipes.
+    By design, endpoints are only instantiated within the `__init__` method of 
the StreamPipesClient.
+
+    Parameters
+    ----------
+    parent_client: StreamPipesClient
+        This parameter expects the instance of the `client.StreamPipesClient` 
the endpoint is attached to.
+
+    """
+
+    @property
+    def _broker(self) -> Broker:
+        """Defines the broker instance that is used to connect to StreamPipes' 
messaging layer.
+
+        This instance enables the client to authenticate to the broker used in 
the target StreamPipes instance,
+        to consume messages from and to write messages to the broker.
+
+        Raises
+        ------
+        MessagingEndpointNotConfiguredError
+            If the endpoint is used before the broker instance is set via 
`configure()`
+
+        Returns
+        -------
+        The broker instance to be used to communicate with
+        StreamPipes' messaging layer.
+        """
+
+        if hasattr(self, "__broker"):
+            return self.__broker
+        raise MessagingEndpointNotConfiguredError(
+            endpoint_name=f"{self=}".split("=")[0],
+        )
+
+    @_broker.setter
+    def _broker(self, broker: Broker) -> None:
+        """Setter method for internal property `broker`"""
+        self.__broker = broker
+
+    @property
+    @abstractmethod
+    def _container_cls(self) -> Type[ResourceContainer]:

Review Comment:
   Is there a reason why you implemented the methode `_container_cls` again, 
even though the `MessagingEndpoint` also inherits it from the `Endpoint` class?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to