-
Notifications
You must be signed in to change notification settings - Fork 98
MONGOCRYPT-763 add in-place retry API #1011
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
base: master
Are you sure you want to change the base?
Changes from all commits
ce988fd
f615153
4cb5326
ab662af
db1b417
ac957c9
63b36a2
7e44b5f
d2951a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
mdb-ad marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1180,14 +1180,24 @@ MONGOCRYPT_EXPORT | |
bool mongocrypt_kms_ctx_feed(mongocrypt_kms_ctx_t *kms, mongocrypt_binary_t *bytes); | ||
|
||
/** | ||
* Indicate a network-level failure. | ||
* Indicate a failure. Discards all data fed to this KMS context with @ref mongocrypt_kms_ctx_feed. | ||
* The @ref mongocrypt_kms_ctx_t may be reused. | ||
* | ||
* @param[in] kms The @ref mongocrypt_kms_ctx_t. | ||
* @return A boolean indicating whether the failed request may be retried. | ||
*/ | ||
MONGOCRYPT_EXPORT | ||
bool mongocrypt_kms_ctx_fail(mongocrypt_kms_ctx_t *kms); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
ASSERT_OK(mongocrypt_kms_ctx_feed(kms, retryable_http), kms); // Increments kms->attempts.
ASSERT(mongocrypt_kms_ctx_should_retry(kms));
ASSERT_OK(mongocrypt_kms_ctx_fail(kms), kms); // Increments kms->attempts again. I like the direction towards simplifying. Suggest resetting the KMS parser in while (true) {
try {
// TODO: Write and read from socket.
} catch (e : NetworkError) {
// Indicate network error:
mongocrypt_kms_ctx_fail (kms);
} finally {
if (mongocrypt_kms_ctx_should_retry (kms)) {
// Can retry due to a HTTP or network error.
continue;
}
}
} That way, Testing this change in 456d523 appears to work. |
||
|
||
/** | ||
* Indicate if a KMS context is completed but should be retried. | ||
* | ||
* @param[in] kms The @ref mongocrypt_kms_ctx_t. | ||
* @return A boolean indicating whether the failed request should be retried. | ||
*/ | ||
MONGOCRYPT_EXPORT | ||
bool mongocrypt_kms_ctx_should_retry(mongocrypt_kms_ctx_t *kms); | ||
|
||
/** | ||
* Get the status associated with a @ref mongocrypt_kms_ctx_t object. | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
HTTP/1.1 200 OK | ||
x-amzn-RequestId: deeb35e5-4ecb-4bf1-9af5-84a54ff0af0e | ||
Content-Type: application/x-amz-json-1.1 | ||
Content-Length: 446 | ||
Connection: close | ||
|
||
{"KeyId": "arn:aws:k |
Uh oh!
There was an error while loading. Please reload this page.