-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add a grpc streaming helper #4
Conversation
Signed-off-by: Sahas Subramanian <[email protected]>
Signed-off-by: Sahas Subramanian <[email protected]>
c40c7f9
to
319e686
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just gave it a quick look. Besides the extra directory levels and considering this is code being moved from somewhere else (so I don't want to do a full review of the code because it is probably a bit out of scope for this PR), LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to put this directly in src/frequenz/client/base/grpc_streaming_helper.py
instead of having a subdirectory with an extra __init__.py
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
|
||
class GrpcStreamingHelper(typing.Generic[_InputT, _OutputT]): | ||
"""Helper class to handle grpc streaming methods.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little more docs with an example would be nice to have.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, why not just src/frequenz/client/base/retry_strategy.py
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that file has a bunch of not-underscore symbols that I didn't want to expose, let me do that in a new commit. Also need to add a NoRetry
strategy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
self._stream_method = stream_method | ||
self._transform = transform | ||
self._retry_spec = ( | ||
retry_strategy.LinearBackoff() if retry_spec is None else retry_spec.copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote a comment to suggest to make retry specs/strategy immutable, so we don't need to copy them. But now I see retry strategies are actually keeping state, so it is not really a spec or a strategy, is more like a tracker, that you need to reset when a connection is complete, so the copy makes sense, but it might be nice to look for a clearer name in the future (in a different PR), RetryTracker
or something more along those lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, not putting the focus on existing code but just on structure in the new repo.
Signed-off-by: Sahas Subramanian <[email protected]>
Signed-off-by: Sahas Subramanian <[email protected]>
69c7a11
to
29c0c6e
Compare
I've squashed the commits and updated release notes. |
This PR extracts the streaming code from the SDK that converts grpc streams into channel receivers, into the generic
GrpcStreamingHelper
.The
RetryStrategy
implementation is also extracted from the SDK.