Refactor AdsClient and switch backoff with tryhard #430
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While looking at investigating how our code handles shutdown signals and seeing how we could improve it, and the code in the
AdsClient
was particularly gnarly to understand, so I've split up the responsibilities of theAdsClient
into distinct types to split the code up, similar to how it was done in #339. Now instead of all the operations being associated functions onAdsClient
, the responsiblities are split up betweenRpcSender
,RpcReceiver
,RpcSession
, andAdsClient
. Like #339 there's no actual behaviour change here.RpcSender
is responsible for sending discovery requests.RpcReceiver
is responsible for handling discovery responses.RpcSession
encapsulates bothRpcSender
andRpcReceiver
into a single session with a server.AdsClient
handlesRpcSession
initiation, failure, and retrying.This PR also replaces using
backoff
for the handling backoff on failure withtryhard
. The motivation being thattryhard
is a lot simpler conceptually and in implementation thanbackoff
, withbackoff
we had to control the backoff ourselves, and pass state back and forth to ensure we can properly retry. Where as now withtryhard
we don't have to do any of that, we just run the future, and that is all taken of for us.