-
Notifications
You must be signed in to change notification settings - Fork 1.1k
refactor(gax): implement clean stateless channel refresh & retry mapping #13342
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
base: main
Are you sure you want to change the base?
Changes from all commits
14fda9c
14ea140
49b08e8
7d02d82
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -97,6 +97,7 @@ public final class GrpcCallContext implements ApiCallContext { | |||||||||||||||||||||||
| private final ApiCallContextOptions options; | ||||||||||||||||||||||||
| private final EndpointContext endpointContext; | ||||||||||||||||||||||||
| private final boolean isDirectPath; | ||||||||||||||||||||||||
| @Nullable private final TransportChannel transportChannel; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** Returns an empty instance with a null channel and default {@link CallOptions}. */ | ||||||||||||||||||||||||
| public static GrpcCallContext createDefault() { | ||||||||||||||||||||||||
|
|
@@ -113,7 +114,8 @@ public static GrpcCallContext createDefault() { | |||||||||||||||||||||||
| null, | ||||||||||||||||||||||||
| null, | ||||||||||||||||||||||||
| null, | ||||||||||||||||||||||||
| false); | ||||||||||||||||||||||||
| false, | ||||||||||||||||||||||||
| null); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** Returns an instance with the given channel and {@link CallOptions}. */ | ||||||||||||||||||||||||
|
|
@@ -131,7 +133,8 @@ public static GrpcCallContext of(Channel channel, CallOptions callOptions) { | |||||||||||||||||||||||
| null, | ||||||||||||||||||||||||
| null, | ||||||||||||||||||||||||
| null, | ||||||||||||||||||||||||
| false); | ||||||||||||||||||||||||
| false, | ||||||||||||||||||||||||
| null); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| private GrpcCallContext( | ||||||||||||||||||||||||
|
|
@@ -147,7 +150,8 @@ private GrpcCallContext( | |||||||||||||||||||||||
| @Nullable RetrySettings retrySettings, | ||||||||||||||||||||||||
| @Nullable Set<StatusCode.Code> retryableCodes, | ||||||||||||||||||||||||
| @Nullable EndpointContext endpointContext, | ||||||||||||||||||||||||
| boolean isDirectPath) { | ||||||||||||||||||||||||
| boolean isDirectPath, | ||||||||||||||||||||||||
| @Nullable TransportChannel transportChannel) { | ||||||||||||||||||||||||
| this.channel = channel; | ||||||||||||||||||||||||
| this.credentials = credentials; | ||||||||||||||||||||||||
| Preconditions.checkNotNull(callOptions); | ||||||||||||||||||||||||
|
|
@@ -167,6 +171,7 @@ private GrpcCallContext( | |||||||||||||||||||||||
| this.endpointContext = | ||||||||||||||||||||||||
| endpointContext == null ? EndpointContext.getDefaultInstance() : endpointContext; | ||||||||||||||||||||||||
| this.isDirectPath = isDirectPath; | ||||||||||||||||||||||||
| this.transportChannel = transportChannel; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||
|
|
@@ -208,7 +213,13 @@ public GrpcCallContext withCredentials(Credentials newCredentials) { | |||||||||||||||||||||||
| retrySettings, | ||||||||||||||||||||||||
| retryableCodes, | ||||||||||||||||||||||||
| endpointContext, | ||||||||||||||||||||||||
| isDirectPath); | ||||||||||||||||||||||||
| isDirectPath, | ||||||||||||||||||||||||
| transportChannel); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||
| public TransportChannel getTransportChannel() { | ||||||||||||||||||||||||
| return transportChannel; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||
|
|
@@ -232,7 +243,8 @@ public GrpcCallContext withTransportChannel(TransportChannel inputChannel) { | |||||||||||||||||||||||
| retrySettings, | ||||||||||||||||||||||||
| retryableCodes, | ||||||||||||||||||||||||
| endpointContext, | ||||||||||||||||||||||||
| transportChannel.isDirectPath()); | ||||||||||||||||||||||||
| transportChannel.isDirectPath(), | ||||||||||||||||||||||||
| inputChannel); | ||||||||||||||||||||||||
|
Comment on lines
243
to
+247
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The parameter of
Suggested change
|
||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||
|
|
@@ -251,7 +263,8 @@ public GrpcCallContext withEndpointContext(EndpointContext endpointContext) { | |||||||||||||||||||||||
| retrySettings, | ||||||||||||||||||||||||
| retryableCodes, | ||||||||||||||||||||||||
| endpointContext, | ||||||||||||||||||||||||
| isDirectPath); | ||||||||||||||||||||||||
| isDirectPath, | ||||||||||||||||||||||||
| transportChannel); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** This method is obsolete. Use {@link #withTimeoutDuration(java.time.Duration)} instead. */ | ||||||||||||||||||||||||
|
|
@@ -286,7 +299,8 @@ public GrpcCallContext withTimeoutDuration(@Nullable java.time.Duration timeout) | |||||||||||||||||||||||
| retrySettings, | ||||||||||||||||||||||||
| retryableCodes, | ||||||||||||||||||||||||
| endpointContext, | ||||||||||||||||||||||||
| isDirectPath); | ||||||||||||||||||||||||
| isDirectPath, | ||||||||||||||||||||||||
| transportChannel); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** This method is obsolete. Use {@link #getTimeoutDuration()} instead. */ | ||||||||||||||||||||||||
|
|
@@ -335,7 +349,8 @@ public GrpcCallContext withStreamWaitTimeoutDuration( | |||||||||||||||||||||||
| retrySettings, | ||||||||||||||||||||||||
| retryableCodes, | ||||||||||||||||||||||||
| endpointContext, | ||||||||||||||||||||||||
| isDirectPath); | ||||||||||||||||||||||||
| isDirectPath, | ||||||||||||||||||||||||
| transportChannel); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||
|
|
@@ -370,7 +385,8 @@ public GrpcCallContext withStreamIdleTimeoutDuration( | |||||||||||||||||||||||
| retrySettings, | ||||||||||||||||||||||||
| retryableCodes, | ||||||||||||||||||||||||
| endpointContext, | ||||||||||||||||||||||||
| isDirectPath); | ||||||||||||||||||||||||
| isDirectPath, | ||||||||||||||||||||||||
| transportChannel); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @BetaApi("The surface for channel affinity is not stable yet and may change in the future.") | ||||||||||||||||||||||||
|
|
@@ -388,7 +404,8 @@ public GrpcCallContext withChannelAffinity(@Nullable Integer affinity) { | |||||||||||||||||||||||
| retrySettings, | ||||||||||||||||||||||||
| retryableCodes, | ||||||||||||||||||||||||
| endpointContext, | ||||||||||||||||||||||||
| isDirectPath); | ||||||||||||||||||||||||
| isDirectPath, | ||||||||||||||||||||||||
| transportChannel); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @BetaApi("The surface for extra headers is not stable yet and may change in the future.") | ||||||||||||||||||||||||
|
|
@@ -410,7 +427,8 @@ public GrpcCallContext withExtraHeaders(Map<String, List<String>> extraHeaders) | |||||||||||||||||||||||
| retrySettings, | ||||||||||||||||||||||||
| retryableCodes, | ||||||||||||||||||||||||
| endpointContext, | ||||||||||||||||||||||||
| isDirectPath); | ||||||||||||||||||||||||
| isDirectPath, | ||||||||||||||||||||||||
| transportChannel); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||
|
|
@@ -433,7 +451,8 @@ public GrpcCallContext withRetrySettings(RetrySettings retrySettings) { | |||||||||||||||||||||||
| retrySettings, | ||||||||||||||||||||||||
| retryableCodes, | ||||||||||||||||||||||||
| endpointContext, | ||||||||||||||||||||||||
| isDirectPath); | ||||||||||||||||||||||||
| isDirectPath, | ||||||||||||||||||||||||
| transportChannel); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||
|
|
@@ -456,7 +475,8 @@ public GrpcCallContext withRetryableCodes(Set<StatusCode.Code> retryableCodes) { | |||||||||||||||||||||||
| retrySettings, | ||||||||||||||||||||||||
| retryableCodes, | ||||||||||||||||||||||||
| endpointContext, | ||||||||||||||||||||||||
| isDirectPath); | ||||||||||||||||||||||||
| isDirectPath, | ||||||||||||||||||||||||
| transportChannel); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @Override | ||||||||||||||||||||||||
|
|
@@ -558,7 +578,8 @@ public ApiCallContext merge(ApiCallContext inputCallContext) { | |||||||||||||||||||||||
| newRetrySettings, | ||||||||||||||||||||||||
| newRetryableCodes, | ||||||||||||||||||||||||
| endpointContext, | ||||||||||||||||||||||||
| newIsDirectPath); | ||||||||||||||||||||||||
| newIsDirectPath, | ||||||||||||||||||||||||
| transportChannel); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** The {@link Channel} set on this context. */ | ||||||||||||||||||||||||
|
|
@@ -641,7 +662,8 @@ public GrpcCallContext withChannel(Channel newChannel) { | |||||||||||||||||||||||
| retrySettings, | ||||||||||||||||||||||||
| retryableCodes, | ||||||||||||||||||||||||
| endpointContext, | ||||||||||||||||||||||||
| isDirectPath); | ||||||||||||||||||||||||
| isDirectPath, | ||||||||||||||||||||||||
| transportChannel); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** Returns a new instance with the call options set to the given call options. */ | ||||||||||||||||||||||||
|
|
@@ -659,7 +681,8 @@ public GrpcCallContext withCallOptions(CallOptions newCallOptions) { | |||||||||||||||||||||||
| retrySettings, | ||||||||||||||||||||||||
| retryableCodes, | ||||||||||||||||||||||||
| endpointContext, | ||||||||||||||||||||||||
| isDirectPath); | ||||||||||||||||||||||||
| isDirectPath, | ||||||||||||||||||||||||
| transportChannel); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| public GrpcCallContext withRequestParamsDynamicHeaderOption(String requestParams) { | ||||||||||||||||||||||||
|
|
@@ -704,7 +727,8 @@ public <T> GrpcCallContext withOption(Key<T> key, T value) { | |||||||||||||||||||||||
| retrySettings, | ||||||||||||||||||||||||
| retryableCodes, | ||||||||||||||||||||||||
| endpointContext, | ||||||||||||||||||||||||
| isDirectPath); | ||||||||||||||||||||||||
| isDirectPath, | ||||||||||||||||||||||||
| transportChannel); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| /** {@inheritDoc} */ | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
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 environment variable
GOOGLE_API_CERTIFICATE_CONFIGis checked, but the innerifblock is empty, meaning the configuration is completely ignored. If the config path points to a valid certificate file, its path should be returned.