-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: async factory function for eager connections
This commit makes the following changes: * Stop trying to do the eager connection stuff in the constructor of the CacheClient, because this can have surprising side effects, e.g. if we want to throw an error on failure. * Remove the associated Configuration settings since we no longer support eager connections at construction time. * Add a new factory function, CacheClient.CreateAsync, which is the new mechanism for create a client with an eager connection. This matches the pattern we established in the other SDKs that support eager connections. * If the eager connection fails, we now throw a new ConnectionError rather than just logging a warning. This gives the consumer the ability to decide how to handle this type of error rather than us just swallowing it and removing their choice. In most cases, users would just end up hitting a timeout error on their next request after we gave up on the eager connection. In the future we may add more configuration options for how to handle eager connection failures, possibly including some automatic retries. For now, this gives the user more control, which seems extremely desirable given the number of times we have recently seen users run into DNS throttling when they try to make a very high volume of connections to Momento from lambdas.
- Loading branch information
Showing
7 changed files
with
62 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Momento.Sdk.Exceptions; | ||
|
||
using System; | ||
|
||
/// <summary> | ||
/// Unable to connect to the server. | ||
/// </summary> | ||
public class ConnectionException : SdkException | ||
{ | ||
/// <include file="../docs.xml" path='docs/class[@name="SdkException"]/constructor/*' /> | ||
public ConnectionException(string message, MomentoErrorTransportDetails transportDetails, Exception? e = null) : base(MomentoErrorCode.CONNECTION_ERROR, message, transportDetails, e) | ||
{ | ||
this.MessageWrapper = "Unable to connect to the server; consider retrying. If the error persists, please contact us at [email protected]"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters