Support a variety of connection strategies and backoff when connecting to domain names #349
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.
This PR adds several features to support more robust procedure when initiating connections and handling their failures. First, this PR adds a new class,
ntsa::Backoff, that represents either an arithmetic or geometric backoff to a progression of a time interval. Second, a optionalntsa::Backoffpolicy is supported in the scheduling of a periodicntci::Timerby specification of the backoff in the associatedntca::TimerOptionsused to create the timer. Third, an optionalntsa::Backoffpolicy can also be indicated in thentca::ConnectOptionsspecified when initiating a new asynchronous connect operation of anntci::StreamSocket. Finally, this PR adds a newntca::ConnectStrategyenumeration, which allows the user to indicate how the resolution of a domain name should be handled when connecting anntci::StreamSocketto a domain name: either "resolve the domain name and pick first address supplied by resolution process, an re-resolve after each connection failure" (the current default, and previous behavior), or "resolve the domain name and try each address to which that name resolves before re-resolving" (the new supported behavior.) The connection strategy is indicated in thentca::ConnectOptionsspecified when initiating an asynchronous connect operation on anntci::StreamSocket.