-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(common): add support for call-tree-specific options (#7669)
Provide access to the prevailing `Options` for an operation without having to plumb function parameters through the various and sundry layers, like connection. This also means that helper libraries can determine things like whether a tracing component is enabled, without having to distort their APIs. For example, if all `ServiceClient::Operation()` calls are implemented like ``` class ServiceClient { public ServiceClient(std::shared_ptr<ServiceConnection> connection, Options options = {}) : connection_(std::move(connection)), options_(ServiceDefaultOptions(std::move(options))) {} T Operation(..., Options options = {}) { internal::OptionsSpan span(internal::MergeOptions(options, options_)); ... } private: std::shared_ptr<ServiceConnection> connection_; Options options_; }; ``` then the connection layer, or any other internal library, can retrieve the prevailing options using `internal::CurrentOptions()`. If the operation is asynchronous, the invocation-time `Options` are also installed during its callbacks.
- Loading branch information
Showing
10 changed files
with
176 additions
and
4 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
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
Oops, something went wrong.