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
feat: add shutdown() and shutdownNow() #673
Changes from 3 commits
7598071
11ceaf0
2e032f2
fc77332
f2c76a1
f416d06
ae5bd94
734bd7e
3f85e64
060a6ca
bdd64df
903f794
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 |
---|---|---|
|
@@ -16,7 +16,6 @@ | |
|
||
package com.google.cloud.firestore.spi.v1; | ||
|
||
import com.google.api.core.ApiFunction; | ||
import com.google.api.gax.core.BackgroundResource; | ||
import com.google.api.gax.core.GaxProperties; | ||
import com.google.api.gax.grpc.GrpcCallContext; | ||
|
@@ -27,8 +26,6 @@ | |
import com.google.api.gax.rpc.NoHeaderProvider; | ||
import com.google.api.gax.rpc.ServerStreamingCallable; | ||
import com.google.api.gax.rpc.TransportChannel; | ||
import com.google.api.gax.rpc.UnaryCallSettings; | ||
import com.google.api.gax.rpc.UnaryCallSettings.Builder; | ||
import com.google.api.gax.rpc.UnaryCallable; | ||
import com.google.cloud.NoCredentials; | ||
import com.google.cloud.ServiceOptions; | ||
|
@@ -38,7 +35,6 @@ | |
import com.google.cloud.firestore.v1.FirestoreClient.ListDocumentsPagedResponse; | ||
import com.google.cloud.firestore.v1.FirestoreSettings; | ||
import com.google.cloud.firestore.v1.stub.FirestoreStub; | ||
import com.google.cloud.firestore.v1.stub.FirestoreStubSettings; | ||
import com.google.cloud.firestore.v1.stub.GrpcFirestoreStub; | ||
import com.google.cloud.grpc.GrpcTransportOptions; | ||
import com.google.cloud.grpc.GrpcTransportOptions.ExecutorFactory; | ||
|
@@ -126,18 +122,7 @@ public GrpcFirestoreRpc(final FirestoreOptions options) throws IOException { | |
|
||
clientContext = ClientContext.create(settingsBuilder.build()); | ||
} | ||
ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> retrySettingsSetter = | ||
new ApiFunction<Builder<?, ?>, Void>() { | ||
@Override | ||
public Void apply(UnaryCallSettings.Builder<?, ?> builder) { | ||
builder.setRetrySettings(options.getRetrySettings()); | ||
return null; | ||
} | ||
}; | ||
FirestoreStubSettings.Builder firestoreBuilder = | ||
FirestoreStubSettings.newBuilder(clientContext) | ||
.applyToAllUnaryMethods(retrySettingsSetter); | ||
firestoreStub = GrpcFirestoreStub.create(firestoreBuilder.build()); | ||
firestoreStub = GrpcFirestoreStub.create(clientContext); | ||
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. @BenWhitehead This might actually be enough to solve the underlying issue in I also do not know what the consequence of not providing the retry settings builder is. 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. I was able to add this back by adding the existing logic from |
||
} catch (Exception e) { | ||
throw new IOException(e); | ||
} | ||
|
@@ -219,6 +204,16 @@ public BidiStreamingCallable<ListenRequest, ListenResponse> listenCallable() { | |
return firestoreStub.listenCallable(); | ||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
firestoreStub.shutdown(); | ||
} | ||
|
||
@Override | ||
public void shutdownNow() { | ||
firestoreStub.shutdownNow(); | ||
} | ||
|
||
// This class is needed solely to get access to protected method setInternalHeaderProvider() | ||
private static class FirestoreSettingsBuilder extends FirestoreSettings.Builder { | ||
private FirestoreSettingsBuilder(FirestoreSettings settings) { | ||
|
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.
These changes are necessary becuse of grpc interrupting the channel while this could still be listenting?
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.
Yes, and the exceptions thrown then do no have status codes. This is all based on local debugging.