You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@streampipes.apache.org by GitBox <gi...@apache.org> on 2023/01/19 20:55:52 UTC

[GitHub] [streampipes] bossenti opened a new pull request, #1126: Chore/introduce messaging endpoint

bossenti opened a new pull request, #1126:
URL: https://github.com/apache/streampipes/pull/1126

   <!--
     ~ Licensed to the Apache Software Foundation (ASF) under one or more
     ~ contributor license agreements.  See the NOTICE file distributed with
     ~ this work for additional information regarding copyright ownership.
     ~ The ASF licenses this file to You under the Apache License, Version 2.0
     ~ (the "License"); you may not use this file except in compliance with
     ~ the License.  You may obtain a copy of the License at
     ~
     ~    http://www.apache.org/licenses/LICENSE-2.0
     ~
     ~ Unless required by applicable law or agreed to in writing, software
     ~ distributed under the License is distributed on an "AS IS" BASIS,
     ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     ~ See the License for the specific language governing permissions and
     ~ limitations under the License.
     ~
     -->
     
     <!--
   Thanks for contributing! Here are some tips you can follow to help us incorporate your contribution quickly and easily:
   1. If this is your first time, please read our contributor guidelines:
       - https://streampipes.apache.org/getinvolved.html
       - https://cwiki.apache.org/confluence/display/STREAMPIPES/Getting+Started
   2. Make sure the PR title is formatted like: `[#<GitHub issue id>] PR title ...`
   3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., `[WIP][#<GitHub issue id>] PR title ...`.
   4. Please write your PR title to summarize what this PR proposes/fixes.
   5. Link the PR to the corresponding GitHub issue (if present) in the `Development` section in the right menu bar. 
   6. Be sure to keep the PR description updated to reflect all changes.
   7. If possible, provide a concise example to reproduce the issue for a faster review.
   8. Make sure tests pass via `mvn clean install`.
   9. (Optional) If the contribution is large, please file an Apache ICLA
       - http://apache.org/licenses/icla.pdf
   -->
   
   ### Purpose
   <!--
   Please clarify what changes you are proposing and describe how those changes will address the issue.
   Furthermore, describe potential consequences the changes might have.
   -->
   Introduce a new kind of kind endpoint.
   The messaging endpoint is designed to community with the StreamPipes messaging layer.
   One of the first implementations of such a messaging endpoint will be the function handler.
   This PR prepares the refactoring of the function handler to better integrate with the existing code structure of the Python client.
   
   ### Remarks
   <!--
   Is there anything left we need to pay attention on?
   Are there some references that might be important? E.g. links to Confluence, or discussions
   on the mailing list or GitHub.
   -->
   PR introduces (a) breaking change(s): no
   
   PR introduces (a) deprecation(s): no
   


-- 
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: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [streampipes] bossenti merged pull request #1126: refactor: introduce messaging endpoint for python client

Posted by "bossenti (via GitHub)" <gi...@apache.org>.
bossenti merged PR #1126:
URL: https://github.com/apache/streampipes/pull/1126


-- 
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: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [streampipes] bossenti commented on a diff in pull request #1126: refactor: introduce messaging endpoint for python client

Posted by "bossenti (via GitHub)" <gi...@apache.org>.
bossenti commented on code in PR #1126:
URL: https://github.com/apache/streampipes/pull/1126#discussion_r1082948882


##########
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:
   Good catch, that's just silly 😅 



-- 
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: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [streampipes] SvenO3 commented on a diff in pull request #1126: refactor: introduce messaging endpoint for python client

Posted by GitBox <gi...@apache.org>.
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: dev-unsubscribe@streampipes.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org