-
Notifications
You must be signed in to change notification settings - Fork 454
[CDRIVER-5916] Deprecate the Hedged-Reads APIs #1889
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
[CDRIVER-5916] Deprecate the Hedged-Reads APIs #1889
Conversation
We now emit deprecation warnings on MSVC as well, and all deprecation warnings now include a string message, if possible.
- Replace use of `BSON_GNUC_DEPRECATED...` with `BSON_DEPRECATED...` - Reformat attribute macros as attributes according to clang-format. - Give dense API listings in public headers some breathing room.
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.
The MSVC deprecation warnings and additional deprecation warning strings are much appreciated. LGTM with comments addressed.
src/libbson/src/bson/bson.h
Outdated
@@ -532,7 +532,7 @@ bson_as_canonical_extended_json (const bson_t *bson, size_t *length); | |||
* Returns: A newly allocated string that should be freed with bson_free(). | |||
*/ | |||
BSON_EXPORT (char *) | |||
bson_as_json (const bson_t *bson, size_t *length) BSON_GNUC_DEPRECATED_FOR (bson_as_legacy_extended_json); | |||
bson_as_json (const bson_t *bson, size_t *length); |
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.
Add back deprecation warning:
BSON_DEPRECATED_FOR (bson_as_legacy_extended_json)
BSON_EXPORT (char *) bson_as_json (const bson_t *bson, size_t *length);
Co-authored-by: Kevin Albertson <[email protected]>
Background
Refer: CDRIVER-5916
DRIVERS-2929 is be a spec update that deprecates Hedge Reads in driver APIs. This changeset adds such deprecation warnings, among other things.
Summary
This does not change any library behavior, it only adds deprecation warnings, and updates those that already exist. Per-commit review is recommended:
BSON_GNUC_DEPRECATED
macros. This macro always requires a deprecation message string, which will be included in the emitted attribute if it is supported by the compiler..clang-format
'sAttributeMacros
to format them as declaration specifiers on functions.bson-atomic.h
andbson-cmp.h
_Pragma
to disable deprecation warnings.Note on Attribute Placement:
MSVC attributes are declaration-specifiers (thus "__declspec"), and thus need to be positioned correctly. The following is ill-formed:
because the
__declspec
is placed between the asterisk and the function name (not a valid position for declaration specifiers). GCC accepts this form, but we cannot use it for compatibility. One possible correct formatting for this declaration would be:but that is a extremely weird, so it's easier to just place the deprecation before the return type:
This has been applied throughout the codebase in ef8347b.