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

feat: wrap async rest methods with retry and error logic #2139

Conversation

ohmayr
Copy link
Contributor

@ohmayr ohmayr commented Sep 10, 2024

This PR adds error handling and retry logic to async rest methods. Note that the callables will be implemented in a follow up PR.

This PR should be reviewed and merged after: #2138.

@ohmayr
Copy link
Contributor Author

ohmayr commented Sep 10, 2024

NOTE: The base branch of this PR should be updated to async-rest-support-in-gapics before merging.

@ohmayr ohmayr force-pushed the wrap-async-methods-with-error-handling-logic branch from 9b98c48 to 8475e46 Compare September 10, 2024 22:40
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Sep 10, 2024
@ohmayr ohmayr force-pushed the wrap-async-methods-with-error-handling-logic branch from 8475e46 to 5fd24b6 Compare September 10, 2024 22:47
@ohmayr ohmayr marked this pull request as draft September 10, 2024 22:51
@ohmayr ohmayr force-pushed the wrap-async-methods-with-error-handling-logic branch from 5fd24b6 to 4c5a9c6 Compare September 10, 2024 22:56
@ohmayr ohmayr marked this pull request as ready for review September 10, 2024 23:06
Copy link
Contributor

@parthea parthea left a comment

Choose a reason for hiding this comment

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

Added non-blocking comment. Feel free to follow up in a later PR

[cloud_redis.CreateInstanceRequest],
operations_pb2.Operation]:

return # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment to clarify the reason that we have # type: ignore here and add TODO bug to follow up on it

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not seeing it...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also a related thread from the PR above it: #2140 (comment).

Base automatically changed from refactor-rest-error-test to async-rest-support-in-gapics September 12, 2024 19:52
@ohmayr ohmayr force-pushed the wrap-async-methods-with-error-handling-logic branch from 79cc77d to 23cb93e Compare September 12, 2024 20:37
[cloud_redis.CreateInstanceRequest],
operations_pb2.Operation]:

return # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

+1

def create_instance(self) -> Callable[
[cloud_redis.CreateInstanceRequest],
operations_pb2.Operation]:

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove this empty blank line for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed.

""" Precompute the wrapped methods, overriding the base class method to use async wrappers."""
self._wrapped_methods = {
self.list_instances: self._wrap_method(
self.list_instances,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: It would be good if we could test a method with retry settings, since those are used in prep_wrapped_messages_async_method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! I think it won't be that straightforward to test retry logic before the actual call methods are implemented (for async rest) . I also think that we should add similar tests for async gRPC.

Filed: #2155

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Retry logic will be tested as part of e2e showcase testing (once we turn them on for async REST) which is something that I just remembered.

[cloud_redis.CreateInstanceRequest],
operations_pb2.Operation]:

return # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

Not seeing it...

@ohmayr ohmayr merged commit e35f0e9 into async-rest-support-in-gapics Sep 12, 2024
71 checks passed
@ohmayr ohmayr deleted the wrap-async-methods-with-error-handling-logic branch September 12, 2024 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants