Set helpful gRPC keepalive defaults
Use the defaults from #9832 across all libraries.
Here is an example of how we can set defaults, while respecting customer-supplied options: https://github.com/googleapis/google-cloud-cpp/blob/f779bb99395bbdfe3aac51864ff2abf2a0b6dffc/google/cloud/bigtable/internal/defaults.cc#L134-L150
Hi, I am looking at this as my first contribution to open source. Not sure what's exactly the default settings should be, can anyone give an example? thanks.
Hey @antonjfernando2021 this is a good first issue. The settings in question are these (e.g. GRPC_ARG_KEEPALIVE_TIME_MS): https://github.com/googleapis/google-cloud-cpp/blob/659fe7072ee7a392dbd4b01be8b8debe2ffef941/google/cloud/storage/internal/storage_stub_factory.cc#L43-L59
The defaults are the values they are set to (e.g. kDisableKeepaliveTime).
In the PR, the defaults were applied to storage only, we want them to apply to all libraries.
There are a few ways to solve the problem. There are things like google::cloud::internal::PopulateGrpcOptions(), which gets called by most (but not all) libraries when they set their defaults.
But what I am going to recommend is that we take the simplest approach and work inside google::cloud::internal::MakeChannelArguments(), which gets called by all libraries: https://github.com/googleapis/google-cloud-cpp/blob/6d936867bdfc5cd3071e5cb35d9a0291d22a106a/google/cloud/grpc_options.cc#L37-L47
The best way to see if your code works is by writing a unit test like this one. I'd start with something like:
TEST(GrpcChannelArguments, MakeChannelArgumentsDefaults) {
auto options = Options{};
auto args = MakeChannelArguments(options);
// TODO : what should be true about `args`?
}
You can run the tests in that file using Bazel with:
bazel test --test_output=all //google/cloud:grpc_options_test
Thanks Darren for the heads up, I will look into this.