Class ChannelPool
A pool of channels for the same service, but with potentially different endpoints. Each endpoint has a single channel. All channels created by this pool use default application credentials. This class is thread-safe.
Inheritance
Inherited Members
Namespace: Google.Api.Gax.Grpc
Assembly: Google.Api.Gax.Grpc.dll
Syntax
public sealed class ChannelPool
Constructors
ChannelPool(IEnumerable<String>)
Creates a channel pool which will apply the specified scopes to the default application credentials if they require any.
Declaration
public ChannelPool(IEnumerable<string> scopes)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | scopes | The scopes to apply. Must not be null, and must not contain null references. May be empty. |
Methods
GetChannel(ServiceEndpoint)
Returns a channel from this pool, creating a new one if there is no channel
already associated with endpoint
. Default channel options are applied.
Declaration
public Channel GetChannel(ServiceEndpoint endpoint)
Parameters
Type | Name | Description |
---|---|---|
ServiceEndpoint | endpoint | The endpoint to connect to. Must not be null. |
Returns
Type | Description |
---|---|
Channel | A channel for the specified endpoint. |
GetChannel(ServiceEndpoint, IEnumerable<ChannelOption>)
Returns a channel from this pool, creating a new one if there is no channel
already associated with endpoint
.
The specified channel options are applied, but only those options.
Declaration
public Channel GetChannel(ServiceEndpoint endpoint, IEnumerable<ChannelOption> channelOptions)
Parameters
Type | Name | Description |
---|---|---|
ServiceEndpoint | endpoint | The endpoint to connect to. Must not be null. |
System.Collections.Generic.IEnumerable<ChannelOption> | channelOptions | The channel options to include. May be null. |
Returns
Type | Description |
---|---|
Channel | A channel for the specified endpoint. |
GetChannelAsync(ServiceEndpoint)
Asynchronously returns a channel from this pool, creating a new one if there is no channel
already associated with endpoint
. Default channel options are applied.
Declaration
public Task<Channel> GetChannelAsync(ServiceEndpoint endpoint)
Parameters
Type | Name | Description |
---|---|---|
ServiceEndpoint | endpoint | The endpoint to connect to. Must not be null. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Channel> | A task representing the asynchronous operation. The value of the completed task will be channel for the specified endpoint. |
GetChannelAsync(ServiceEndpoint, IEnumerable<ChannelOption>)
Asynchronously returns a channel from this pool, creating a new one if there is no channel
already associated with endpoint
.
The specified channel options are applied, but only those options.
Declaration
public Task<Channel> GetChannelAsync(ServiceEndpoint endpoint, IEnumerable<ChannelOption> channelOptions)
Parameters
Type | Name | Description |
---|---|---|
ServiceEndpoint | endpoint | The endpoint to connect to. Must not be null. |
System.Collections.Generic.IEnumerable<ChannelOption> | channelOptions | The channel options to include. May be null. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<Channel> | A task representing the asynchronous operation. The value of the completed task will be channel for the specified endpoint. |
ShutdownChannelsAsync()
Shuts down all the currently-allocated channels asynchronously. This does not prevent the channel pool from being used later on, but the currently-allocated channels will not be reused.
Declaration
public Task ShutdownChannelsAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A task which will complete when all the (current) channels have been shut down. |