Skip to content

Commit ead714b

Browse files
authored
impl(storage): configure gRPC ClientContext using CurrentOptions (#9453)
1 parent 67079b9 commit ead714b

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

google/cloud/storage/internal/grpc_configure_client_context.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "google/cloud/storage/internal/generic_request.h"
1919
#include "google/cloud/storage/version.h"
20+
#include "google/cloud/grpc_options.h"
2021
#include <grpcpp/client_context.h>
2122

2223
namespace google {
@@ -57,6 +58,9 @@ void ApplyQueryParameters(grpc::ClientContext& context, Request const& request,
5758
if (!prefix.empty()) field_mask = prefix + "(" + field_mask + ")";
5859
context.AddMetadata("x-goog-fieldmask", std::move(field_mask));
5960
}
61+
62+
google::cloud::internal::ConfigureContext(
63+
context, google::cloud::internal::CurrentOptions());
6064
}
6165

6266
} // namespace internal

google/cloud/storage/internal/grpc_configure_client_context_test.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace {
2727
using ::google::cloud::testing_util::ValidateMetadataFixture;
2828
using ::testing::Contains;
2929
using ::testing::IsEmpty;
30+
using ::testing::MockFunction;
3031
using ::testing::Pair;
3132

3233
class GrpcConfigureClientContext : public ::testing::Test {
@@ -101,6 +102,19 @@ TEST_F(GrpcConfigureClientContext, ApplyQueryParametersQuotaUserAndUserIp) {
101102
}
102103
}
103104

105+
TEST_F(GrpcConfigureClientContext, ApplyQueryParametersGrpcOptions) {
106+
MockFunction<void(grpc::ClientContext&)> mock;
107+
EXPECT_CALL(mock, Call);
108+
109+
google::cloud::internal::OptionsSpan span(
110+
Options{}.set<google::cloud::internal::GrpcSetupOption>(
111+
mock.AsStdFunction()));
112+
113+
grpc::ClientContext context;
114+
ApplyQueryParameters(context,
115+
ReadObjectRangeRequest("test-bucket", "test-object"));
116+
}
117+
104118
} // namespace
105119
} // namespace internal
106120
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END

0 commit comments

Comments
 (0)