Class ClientBuilderBase<TClient>
Base class for API-specific builders.
Inheritance
Inherited Members
Namespace: Google.Api.Gax.Grpc
Assembly: Google.Api.Gax.Grpc.dll
Syntax
public abstract class ClientBuilderBase<TClient>
Type Parameters
Name | Description |
---|---|
TClient | The type of client created by this builder. |
Constructors
ClientBuilderBase()
Creates a new instance with no settings.
Declaration
protected ClientBuilderBase()
Properties
CallInvoker
The call invoker to use, or null to create the call invoker when the client is built.
Declaration
public CallInvoker CallInvoker { get; set; }
Property Value
Type | Description |
---|---|
CallInvoker |
CanUseChannelPool
Returns whether or not a channel pool can be used if a channel is required. The default behavior is to return true if and only if no scopes, credentials or token access method have been specified. Derived classes should override this property if there are other reasons why the channel pool should not be used.
Declaration
protected virtual bool CanUseChannelPool { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
ChannelCredentials
The channel credentials to use, or null if credentials are being provided in a different way.
Declaration
public ChannelCredentials ChannelCredentials { get; set; }
Property Value
Type | Description |
---|---|
ChannelCredentials |
CredentialsPath
The path to the credentials file to use, or null if credentials are being provided in a different way.
Declaration
public string CredentialsPath { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Endpoint
The endpoint to connect to, or null to use the default endpoint.
Declaration
public ServiceEndpoint Endpoint { get; set; }
Property Value
Type | Description |
---|---|
ServiceEndpoint |
JsonCredentials
The credentials to use as a JSON string, or null if credentials are being provided in a different way.
Declaration
public string JsonCredentials { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Scopes
The scopes to use, or null to use the default scopes.
Declaration
public IReadOnlyList<string> Scopes { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<System.String> |
TokenAccessMethod
The token access method to use, or null if credentials are being provided in a different way.
Declaration
public Func<string, CancellationToken, Task<string>> TokenAccessMethod { get; set; }
Property Value
Type | Description |
---|---|
System.Func<System.String, System.Threading.CancellationToken, System.Threading.Tasks.Task<System.String>> |
Remarks
To use a GoogleCredential for credentials, set this property using a method group conversion, e.g.
TokenAccessMethod = credential.GetAccessTokenForRequestAsync
UserAgent
A custom user agent to specify in the channel metadata, or null if no custom user agent is required.
Declaration
public string UserAgent { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Methods
Build()
Builds the resulting client.
Declaration
public abstract TClient Build()
Returns
Type | Description |
---|---|
TClient |
BuildAsync(CancellationToken)
Builds the resulting client asynchronously.
Declaration
public abstract Task<TClient> BuildAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<TClient> |
CopyCommonSettings<TOther>(ClientBuilderBase<TOther>)
Copies common settings from the specified builder into this one. This is a shallow copy.
Declaration
protected void CopyCommonSettings<TOther>(ClientBuilderBase<TOther> source)
Parameters
Type | Name | Description |
---|---|---|
ClientBuilderBase<TOther> | source | The builder to copy from. |
Type Parameters
Name | Description |
---|---|
TOther | The other client type |
CreateCallInvoker()
Creates a call invoker synchronously. Override this method in a concrete builder type if more call invoker mechanisms are supported. This implementation calls GetChannelCredentials() if no call invoker is specified.
Declaration
protected virtual CallInvoker CreateCallInvoker()
Returns
Type | Description |
---|---|
CallInvoker |
CreateCallInvokerAsync(CancellationToken)
Creates a call invoker asynchronously. Override this method in a concrete builder type if more call invoker mechanisms are supported. This implementation calls GetChannelCredentialsAsync(CancellationToken) if no call invoker is specified.
Declaration
protected virtual Task<CallInvoker> CreateCallInvokerAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<CallInvoker> |
GetChannelCredentials()
Obtains channel credentials synchronously. Override this method in a concrete builder type if more credential mechanisms are supported.
Declaration
protected virtual ChannelCredentials GetChannelCredentials()
Returns
Type | Description |
---|---|
ChannelCredentials |
GetChannelCredentialsAsync(CancellationToken)
Obtains channel credentials asynchronously. Override this method in a concrete builder type if more credential mechanisms are supported.
Declaration
protected virtual Task<ChannelCredentials> GetChannelCredentialsAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
System.Threading.CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ChannelCredentials> |
GetChannelOptions()
Returns the options to use when creating a channel.
Declaration
protected virtual IReadOnlyList<ChannelOption> GetChannelOptions()
Returns
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<ChannelOption> | The options to use when creating a channel. |
GetChannelPool()
Returns the channel pool to use when no other options are specified. This method is not called unless CanUseChannelPool returns true, so if a channel pool is unavailable, override that property to return false and throw an exception from this method.
Declaration
protected abstract ChannelPool GetChannelPool()
Returns
Type | Description |
---|---|
ChannelPool |
GetDefaultEndpoint()
Returns the endpoint for this builder type, used if no endpoint is otherwise specified.
Declaration
protected abstract ServiceEndpoint GetDefaultEndpoint()
Returns
Type | Description |
---|---|
ServiceEndpoint |
GetDefaultScopes()
Returns the default scopes for this builder type, used if no scopes are otherwise specified.
Declaration
protected abstract IReadOnlyList<string> GetDefaultScopes()
Returns
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<System.String> |
Validate()
Validates that the builder is in a consistent state for building. For example, it's invalid to call Build() on an instance which has both JSON credentials and a credentials path specified.
Declaration
protected virtual void Validate()
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The builder is in an invalid state. |
ValidateAtMostOneNotNull(String, Object[])
Validates that at most one of the given values is not null.
Declaration
protected void ValidateAtMostOneNotNull(string message, params object[] values)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The message if the condition is violated. |
System.Object[] | values | The values to check for nullity. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | More than one value is null. |
ValidateOptionExcludesOthers(String, Object, Object[])
Validates that if controlling
is not null, then every value in values
is null.
Declaration
protected void ValidateOptionExcludesOthers(string message, object controlling, params object[] values)
Parameters
Type | Name | Description |
---|---|---|
System.String | message | The message if the condition is violated. |
System.Object | controlling | The value controlling whether or not any other value can be non-null. |
System.Object[] | values | The values checked for non-nullity if |