This repository has been archived by the owner on Sep 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 107
Make ServiceApiSettings provider interfaces public #75
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
429be45
Make ServiceApiSettings provider interfaces public
michaelbausor 94ba6a1
Use executor for channel
michaelbausor 566052f
Restructed Provider interfaces for ServiceApiSettings
michaelbausor 82ab4a2
Updated annotations
michaelbausor 0d24ef5
Changed exception type
michaelbausor 3169d16
Fixes and improvements
michaelbausor f0ea68c
Renamed getChannel/getExecutor methods for providers
michaelbausor 1992d36
Renamed getX methods in interfaces, removed throws IllegalState
michaelbausor 8f34a6e
Updated comments
michaelbausor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/com/google/api/gax/core/CredentialsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.google.api.gax.core; | ||
|
||
import com.google.auth.Credentials; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Provides an interface to hold and acquire the credentials that will be used to call the service. | ||
*/ | ||
public interface CredentialsProvider { | ||
/** | ||
* Gets the credentials which will be used to call the service. If the credentials have not been | ||
* acquired yet, then they will be acquired when this function is called. | ||
*/ | ||
Credentials getCredentials() throws IOException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/com/google/api/gax/grpc/ChannelProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.google.api.gax.grpc; | ||
|
||
import com.google.api.gax.core.ConnectionSettings; | ||
|
||
import io.grpc.ManagedChannel; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.Executor; | ||
|
||
import javax.annotation.Nullable; | ||
import javax.naming.OperationNotSupportedException; | ||
|
||
/** | ||
* Provides an interface to hold and build the channel that will be used. If the channel does not | ||
* already exist, it will be constructed when {@link #getChannel} is called. | ||
* | ||
* Implementations of {@link ChannelProvider} may choose to create a new {@link ManagedChannel} for | ||
* each call to {@link #getChannel}, or may return a fixed {@link ManagedChannel} instance. In cases | ||
* where the same {@link ManagedChannel} instance is returned, for example by a | ||
* {@link ChannelProvider} created using the | ||
* {@link ServiceApiSettings#provideChannelWith(ManagedChannel, boolean)} method, and | ||
* shouldAutoClose returns true, the {@link #getChannel} method will throw an | ||
* {@link OperationNotSupportedException} if it is called more than once. This is to prevent the | ||
* same {@link ManagedChannel} being closed prematurely when it is used by multiple client objects. | ||
*/ | ||
public interface ChannelProvider { | ||
/** | ||
* Connection settings used to build the channel. If a channel is provided directly this will be | ||
* set to null. | ||
*/ | ||
@Nullable | ||
ConnectionSettings connectionSettings(); | ||
|
||
/** | ||
* Indicates whether the channel should be closed by the containing API class. | ||
*/ | ||
boolean shouldAutoClose(); | ||
|
||
/** | ||
* Get the channel to be used to connect to the service. The first time this is called, if the | ||
* channel does not already exist, it will be created. | ||
* | ||
* If the {@link ChannelProvider} is configured to return a fixed {@link ManagedChannel} object | ||
* and to return shouldAutoClose as true, then after the first call to {@link #getChannel}, | ||
* subsequent calls should throw an {@link OperationNotSupportedException}. See interface level | ||
* docs for {@link ChannelProvider} for more details. | ||
*/ | ||
ManagedChannel getChannel(Executor executor) throws IOException, OperationNotSupportedException; | ||
This comment was marked as spam.
Sorry, something went wrong. |
||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/com/google/api/gax/grpc/ExecutorProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.google.api.gax.grpc; | ||
|
||
import java.util.concurrent.ScheduledExecutorService; | ||
|
||
import javax.naming.OperationNotSupportedException; | ||
|
||
/** | ||
* Provides an interface to hold and create the Executor to be used. If the executor does not | ||
* already exist, it will be constructed when {@link #getExecutor} is called. | ||
* | ||
* Implementations of ExecutorProvider may choose to create a new {@link ScheduledExecutorService} | ||
* for each call to {@link #getExecutor}, or may return a fixed {@link ScheduledExecutorService} | ||
* instance. In cases where the same {@link ScheduledExecutorService} instance is returned, for | ||
* example by an {@link ExecutorProvider} created using the | ||
* {@link ServiceApiSettings#provideExecutorWith(ScheduledExecutorService, boolean)} method, and | ||
* shouldAutoClose returns true, the {@link #getExecutor} method will throw an | ||
* {@link OperationNotSupportedException} if it is called more than once. This is to prevent the | ||
* same {@link ScheduledExecutorService} being closed prematurely when it is used by multiple client | ||
* objects. | ||
*/ | ||
public interface ExecutorProvider { | ||
/** | ||
* Indicates whether the channel should be closed by the containing API class. | ||
*/ | ||
boolean shouldAutoClose(); | ||
|
||
/** | ||
* Get the executor to be used to connect to the service. The first time this is called, if the | ||
* executor does not already exist, it will be created. | ||
* | ||
* If the {@link ExecutorProvider} is configured to return a fixed | ||
* {@link ScheduledExecutorService} object and to return shouldAutoClose as true, then after the | ||
* first call to {@link #getExecutor}, subsequent calls should throw an {@link ExecutorProvider}. | ||
This comment was marked as spam.
Sorry, something went wrong. |
||
* See interface level docs for {@link ExecutorProvider} for more details. | ||
*/ | ||
ScheduledExecutorService getExecutor() throws OperationNotSupportedException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong.