File tree Expand file tree Collapse file tree 2 files changed +7
-10
lines changed
src/main/java/com/google/devtools/build/lib/authandtls Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -116,19 +116,15 @@ public class AuthAndTLSOptions extends OptionsBase {
116116
117117 @ Option (
118118 name = "grpc_keepalive_time" ,
119- defaultValue = "null " ,
119+ defaultValue = "60s " ,
120120 converter = DurationConverter .class ,
121121 documentationCategory = OptionDocumentationCategory .UNCATEGORIZED ,
122122 effectTags = {OptionEffectTag .UNKNOWN },
123123 help =
124124 """
125125 Configures keep-alive pings for outgoing gRPC connections. If this is set, then Bazel
126126 sends pings after this much time of no read operations on the connection, but
127- only if there is at least one pending gRPC call. Times are treated as second
128- granularity; it is an error to set a value less than one second. By default,
129- keep-alive pings are disabled. You should coordinate with the service owner
130- before enabling this setting. For example to set a value of 30 seconds to this
131- flag, it should be done as this `--grpc_keepalive_time=30s`.
127+ only if there is at least one pending gRPC call. The value 0 disables the keep-alives.
132128 """ )
133129 public Duration grpcKeepaliveTime ;
134130
Original file line number Diff line number Diff line change 1414
1515package com .google .devtools .build .lib .authandtls ;
1616
17+ import static java .util .concurrent .TimeUnit .NANOSECONDS ;
18+
1719import com .github .benmanes .caffeine .cache .Cache ;
1820import com .google .auth .Credentials ;
1921import com .google .auth .oauth2 .GoogleCredentials ;
5557import java .util .Map ;
5658import java .util .Optional ;
5759import java .util .concurrent .Executor ;
58- import java .util .concurrent .TimeUnit ;
5960import javax .annotation .Nullable ;
6061
6162/** Utility methods for using {@link AuthAndTLSOptions} with Google Cloud. */
@@ -89,9 +90,9 @@ public static ManagedChannel newChannel(
8990 .executor (executor )
9091 .negotiationType (
9192 isTlsEnabled (target ) ? NegotiationType .TLS : NegotiationType .PLAINTEXT );
92- if (options .grpcKeepaliveTime != null ) {
93- builder .keepAliveTime (options .grpcKeepaliveTime .toSeconds (), TimeUnit . SECONDS );
94- builder .keepAliveTimeout (options .grpcKeepaliveTimeout .toSeconds (), TimeUnit . SECONDS );
93+ if (options .grpcKeepaliveTime != null && ! options . grpcKeepaliveTime . isZero () ) {
94+ builder .keepAliveTime (options .grpcKeepaliveTime .toNanos (), NANOSECONDS );
95+ builder .keepAliveTimeout (options .grpcKeepaliveTimeout .toNanos (), NANOSECONDS );
9596 }
9697 if (interceptors != null ) {
9798 builder .intercept (interceptors );
You can’t perform that action at this time.
0 commit comments