-
Notifications
You must be signed in to change notification settings - Fork 54
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: Implement awaitTermination() for MangedHttpJsonChannel #1677
Conversation
gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java
Show resolved
Hide resolved
gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java
Show resolved
Hide resolved
gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java
Outdated
Show resolved
Hide resolved
gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java
Show resolved
Hide resolved
Added additional comments to the PR. I'll add a section for our docs. |
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.
Thanks Lawrence, the general approach makes sense if we can confirm that using a default executor from InstantiatingHttpJsonChannelProvider
is fine. Also can you please add some tests to it? I know we didn't have any unit tests for it previously and it would be tricky to test executors.
gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java
Show resolved
Hide resolved
gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java
Show resolved
Hide resolved
gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java
Show resolved
Hide resolved
gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java
Outdated
Show resolved
Hide resolved
gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java
Outdated
Show resolved
Hide resolved
gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/ManagedHttpJsonChannel.java
Show resolved
Hide resolved
@@ -54,6 +54,9 @@ public Thread newThread(Runnable runnable) { | |||
return thread; | |||
} | |||
}; | |||
private static final int MIN_CPU_AMOUNT = 4; |
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.
This should be MIN_THREAD_AMOUNT
?
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.
Sure. Updating.
public static Builder newBuilder() { | ||
int numCpus = Runtime.getRuntime().availableProcessors(); | ||
int numThreads = Math.max(4, numCpus); | ||
int numThreads = Math.max(MIN_CPU_AMOUNT, numCpus); |
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.
I was expecting this change only in ManagedHttpJsonChannel
, changing it here should be fine as well, but be aware that changing this in InstantiatingExecutorProvider
would affect the current background tasks used for grpc.
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.
Makes sense.I created a new builder: newIOBuilder
that should only be used for HttpJson's async calls and wouldn't change the background executor.
[gapic-generator-java-root] SonarCloud Quality Gate failed. |
[java_showcase_integration_tests] SonarCloud Quality Gate failed. |
[java_showcase_unit_tests] SonarCloud Quality Gate failed. |
Thank you for opening a Pull Request! For general contributing guidelines, please refer to contributing guide
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes: #1663