Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode request reply #161

Merged
merged 6 commits into from
Sep 26, 2023
Merged

Decode request reply #161

merged 6 commits into from
Sep 26, 2023

Conversation

edgarriba
Copy link
Member

No description provided.

@Hackerman342
Copy link
Collaborator

@edgarriba the decode option in the client looks good and makes a lot of sense. But what is the advantage / use case on the service side?

Copy link
Collaborator

@Hackerman342 Hackerman342 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes to the client look good. The changes to event_service.py seem over complicated to me when compared to just decoding the request in the request_reply_handler as necessary. But implementation looks good if we do want this feature.

@@ -145,6 +149,23 @@ def request_reply_handler(self, handler: Callable) -> None:
"""Sets the request/reply handler."""
self._request_reply_handler = handler

def add_request_reply_handler(self, handler: Callable) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be used in the setter above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's more safer from user perspective to have a method which includes logic to avoid that they directly manipulate the member function (even via setter decorators). The motivation of this feature is same as before, to remove boilerplate code for calling payload_to_protobuf in the callbacks on the user side. In the way it's done is backward compatible but i would advocate to use/update the new function in future version to make it more safe.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But as it is right now, there are two ways to set the request_reply_handler and a user could easily make the mistake of setting:

myEventService.request_reply_handler = my_handler_that _expects_two_args

To me it seems much safer if we change to:

    @request_reply_handler.setter
    def request_reply_handler(self, handler: Callable) -> None:
        """Sets the request/reply handler."""
        # self._request_reply_handler = handler
        self.add_request_reply_handler(handler)

That or we remove the setter altogether. As it is right now there is too much error potential

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you've already merged I moved it to #165

@edgarriba edgarriba merged commit 819c51f into main Sep 26, 2023
5 checks passed
@edgarriba edgarriba deleted the decode-request-reply branch September 26, 2023 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants