Google.Api.Gax.Grpc
Bridge between a duplex streaming RPC method and higher level
abstractions, applying call settings as required.
RPC request type
RPC response type
The base for this API call; these can be further overridden by providing
a CallSettings to .
Streaming settings.
Initializes a streaming RPC call.
The call settings to apply to this specific call,
overriding defaults where necessary.
A gRPC duplex streaming call object.
Returns a new API call using the original base call settings merged with .
Where there's a conflict, the original base call settings have priority.
Adapter used to mask the fact that when we need response/trailing metadata, a sync call may need
to use the async gRPC code.
Bridge between an RPC method (with synchronous and asynchronous variants) and higher level
abstractions, applying call settings as required.
RPC request type
RPC response type
The base for this API call; these can be further overridden by providing
a CallSettings to or .
Performs an RPC call asynchronously.
The RPC request.
The call settings to apply to this specific call,
overriding defaults where necessary.
A task representing the asynchronous operation. The result of the completed task
will be the RPC response.
Performs an RPC call synchronously.
The RPC request.
The call settings to apply to this specific call,
overriding defaults where necessary.
The RPC response.
Returns a new API call using the original base call settings merged with .
Where there's a conflict, the original base call settings have priority.
Constructs a new that applies an overlay to
the underlying . If a value exists in both the original and
the overlay, the overlay takes priority.
Function that builds the overlay .
A new with the overlay applied.
Constructs a new that applies an x-goog-request-params header to each request,
using the specified parameter name and a value derived from the request.
Values produced by the function are URL-encoded; it is expected that is already URL-encoded.
The parameter name in the header. Must not be null.
A function to call on each request, to determine the value to specify in the header.
The parameter must not be null, but may return null.
A new which applies the header on each request.
Constructs a new that applies an x-goog-request-params header to each request,
using the .
Values produced by the function are URL-encoded.
The that extracts the value of the routing header from a request.
>A new which applies the header on each request.
Bridge between a client streaming RPC method and higher level
abstractions, applying call settings as required.
RPC request type
RPC response type
The base for this API call; these can be further overridden by providing
a CallSettings to .
Streaming settings.
Initializes a streaming RPC call.
The call settings to apply to this specific call,
overriding defaults where necessary.
A gRPC client streaming call object.
Returns a new API call using the original base call settings merged with .
Where there's a conflict, the original base call settings have priority.
Provides metadata about an API. This is expected to be constructed with a single instance
per API; equality is by simple identity.
The protobuf descriptors used by this API.
A type registry containing all the types in .
The name of the API (typically the fully-qualified name of the client library package).
This is never null or empty.
When true, will request that enums are encoded as numbers in JSON
rather than as strings, preserving unknown values.
A dictionary (based on ordinal string comparisons) from fully-qualified RPC names
to byte strings representing overrides for the HTTP rule. This is designed to support
mixins which are hosted at individual APIs, but which are exposed via different URLs
to the original mixin definition. This is never null, but may be empty.
Creates an API descriptor from a sequence of file descriptors.
The sequence is evaluated once, on construction.
The name of the API. Must not be null or empty.
The protobuf descriptors of the API. Must not be null.
Method used in the above constructor to create the lazy provider.
(Unfortunately this can't be a local method.)
Creates an API descriptor which lazily requests the protobuf descriptors when is first called.
The name of the API. Must not be null or empty.
A provider function for the protobuf descriptors of the API. Must not be null, and must not
return a null value. This will only be called once by this API descriptor, when first requested.
Method used in the above constructor to create the lazy provider.
(Unfortunately this can't be a local method.)
Returns a new instance based on this one, but with the specified value for .
The desired value of in the new instance.
The new instance.
Creates a new instance with the same values as this one, other than the given set of HttpRule overrides.
The HttpRule overrides for services in this package; typically used to override
URLs for the REST transport. Must not be null. Will be cloned in the form of an immutable dictionary,
after which the original sequence is discarded.
The new instance.
Bridge between a server streaming RPC method and higher level
abstractions, applying call settings as required.
RPC request type
RPC response type
The base for this API call; these can be further overridden by providing
a CallSettings to .
Initializes a streaming RPC call asynchronously.
The RPC request.
The call settings to apply to this specific call,
overriding defaults where necessary.
A task representing the gRPC duplex streaming call object.
Initializes a streaming RPC call.
The RPC request.
The call settings to apply to this specific call,
overriding defaults where necessary.
A gRPC duplex streaming call object.
Returns a new API call using the original base call settings merged with .
Where there's a conflict, the original base call settings have priority.
Constructs a new that applies an overlay to
the underlying . If a value exists in both the original and
the overlay, the overlay takes priority.
Function that builds the overlay .
A new with the overlay applied.
Constructs a new that applies an x-goog-request-params header to each request,
using the specified parameter name and a value derived from the request.
Values produced by the function are URL-encoded; it is expected that is already URL-encoded.
The parameter name in the header. Must not be null.
A function to call on each request, to determine the value to specify in the header.
The parameter must not be null, but may return null.
A new which applies the header on each request.
Constructs a new that applies an x-goog-request-params header to each request,
using the .
Values produced by the function are URL-encoded.
The that extracts the value of the routing header from a request.
>A new which applies the header on each request.
An adapter from the gRPC stream representation () to
and . Note that can only
be called once per instance due to the "only iterate once" nature of the response stream.
This type implements both of the standard asynchronous sequence interfaces for simplicity of use:
- C# 8 users can use await foreach because it implements
- It's compatible with the System.Linq.Async package for query transformations.
- Pre-C# 8 users who will be calling and directly don't need
to call .
The response type.
Begins iterating over the response stream, using the specified cancellation token. This method can only be called
once per instance.
The cancellation token to use in subsequent calls.
This method has already been called on this instance.
An iterator over the response stream.
Moves to the next item, using the specified cancellation token.
The cancellation token to use for this step.
A task that will complete with a result of true if the enumerator was successfully advanced to the next element, or false if the enumerator has passed the end of the collection.
Moves to the next item, using the cancellation token configured by .
Base class for bidirectional streaming RPC methods. This wraps an underlying call returned by gRPC,
in order to provide a wrapper for the async response stream, allowing users to take advantage
of await foreach
support from C# 8 onwards. Additionally, it wraps the
request stream in a buffer, allowing multiple requests to be written without waiting for them
to be transmitted.
To avoid memory leaks, users must dispose of gRPC streams.
Additionally, you are strongly advised to read the whole response stream, even if the data
is not required - this avoids effectively cancelling the call.
RPC request type
RPC response type
The underlying gRPC duplex streaming call.
Warning: DO NOT USE GrpcCall.RequestStream at all if using
, ,
, or .
Doing so will cause conflict with the write-buffer used within the [Try]WriteAsync methods.
Writes a message to the stream, if there is enough space in the buffer and
hasn't already been called. The same write options will be used as for the previous message.
The message to write.
null if the message queue is full or the stream has already been completed;
otherwise, a which will complete when the message has been written to the stream.
Writes a message to the stream, if there is enough space in the buffer and
hasn't already been called. The same write options will be used as for the previous message.
The message to write.
There isn't enough space left in the buffer,
or has already been called.
A which will complete when the message has been written to the stream.
Writes a message to the stream, if there is enough space in the buffer and
hasn't already been called.
The message to write.
The write options to use for this message.
null if the message queue is full or the stream has already been completed.
Writes a message to the stream, if there is enough space in the buffer and
hasn't already been called.
The message to write.
The write options to use for this message.
There isn't enough space left in the buffer,
or has already been called.
A which will complete when the message has been written to the stream.
Completes the stream when all buffered messages have been sent.
Only the first call to this method on any instance will have any effect;
subsequent calls will return null.
A which will complete when the stream has finished being completed;
or null if this method has already been called.
Completes the stream when all buffered messages have been sent. This method can only be called
once, and further messages cannot be written after it has been called.
This method has already been called.
A which will complete when the stream has finished being completed.
Async stream to read streaming responses, exposed as an async sequence.
The default implementation will use to extract a response
stream, and adapt it to .
If this method is called more than once, all the returned enumerators will be enumerating over the
same underlying response stream, which may cause confusion. Additionally, the sequence returned by
this method can only be iterated over a single time. Attempting to iterate more than once will cause
an .
Disposes of the underlying gRPC call. There is no need to dispose of both the wrapper
and the underlying call; it's typically simpler to dispose of the wrapper with a
using
statement as the wrapper is returned by client libraries.
The default implementation just calls Dispose on the result of .
Settings for bidirectional streaming.
Configure settings for bidirectional streaming.
The capacity of the write buffer.
The capacity of the write buffer, that locally buffers streaming requests
before they are sent to the server.
A wrapper around which removes the "one write at a time"
restriction by buffering messages (and the completion signal) up to a given capacity.
The type of message in the stream.
Queue of requests. If this is non-empty, there's at least one request in-flight, which
is always the head of the queue.
The capacity of the writer.
The number of write calls that have been buffered.
The value of this property may change due to activity from other threads. It should only be used
for testing and similar scenarios where the system state is well understood.
Constructs an instance which writes to the specified writer, and with the given capacity.
The writer to delegate to.
The maximum number of messages to buffer.
Writes a message to the stream, if there is enough space in the buffer and
hasn't already been called. The same write options will be used as for the previous message.
The message to write.
null if the message queue is full or the stream has already been completed;
otherwise, a which will complete when the message has been written to the stream.
Writes a message to the stream, if there is enough space in the buffer and
hasn't already been called.
The message to write.
The write options to use for this message.
null if the message queue is full or the stream has already been completed.
Writes a message to the stream, if there is enough space in the buffer and
hasn't already been called. The same write options will be used as for the previous message.
The message to write.
There isn't enough space left in the buffer,
or the stream has been completed.
A which will complete when the message has been written to the stream.
Writes a message to the stream, if there is enough space in the buffer and
hasn't already been called.
The message to write.
The write options to use for this message.
There isn't enough space left in the buffer,
or has already been called.
A which will complete when the message has been written to the stream.
One of the writes completes - possibly successfully, possibly not. On success,
we start the next write (or complete) sending if there is one. On failure, we propagate the result
of this task to all other tasks. Those will in turn trigger further calls to this method,
but by that time we'll have retained the failed task so we can just exit quickly.
Validates that we can write to the stream, optionally throwing if there's an error.
This is basically to avoid a big chunk of code appearing in WriteAsyncImpl.
Completes the stream when all buffered messages have been sent, if there is enough space in the buffer.
This method can only be successfully called once, and further messages cannot be written after it
has been successfully called.
null if this stream has already be completed, or if the buffer is full; otherwise a
which will complete when the stream has finished being completed.
Completes the stream when all buffered messages have been sent, if there is enough space in the buffer.
This method can only be successfully called once, and further messages cannot be written after it
has been successfully called.
This stream has already be completed, or the buffer is full
A which will complete when the stream has finished being completed.
Settings to determine how an RPC operates. This type is immutable.
Constructs an instance with the specified settings.
Cancellation token that can be used for cancelling the call.
to use, or null for default expiration behavior.
to use, or null for default retry behavior.
Action to modify the headers to send at the beginning of the call.
that will be used for the call.
for propagating settings from a parent call.
Constructs an instance with the specified settings.
Cancellation token that can be used for cancelling the call.
to use, or null for default expiration behavior.
to use, or null for default retry behavior.
Action to modify the headers to send at the beginning of the call.
that will be used for the call.
for propagating settings from a parent call.
Action to invoke when response metadata is received.
Action to invoke when trailing metadata is received.
Delegate to mutate the metadata which will be sent at the start of the call,
typically to add custom headers.
Cancellation token that can be used for cancelling the call.
that will be used for the call.
for propagating settings from a parent call.
The expiration for the call (either a timeout or a deadline), or null for the default expiration.
to use, or null for default retry behavior.
Delegate to receive the metadata associated with a response.
Delegate to receive the metadata sent after the response.
Merges the settings in with those in
, with taking priority.
If both arguments are null, the result is null. If one argument is null,
the other argument is returned. Otherwise, a new object is created with a property-wise
overlay. Any header mutations are combined, however: the mutation from the original is
performed, then the mutation in the overlay.
Original settings. May be null.
Settings to overlay. May be null.
A merged set of call settings.
Creates a for the specified cancellation token.
The cancellation token for the new settings.
A new instance.
Creates a for the specified call expiration, or returns null
if is null.
The call timing for the new settings.
A new instance or null if is null..
Creates a for the specified retry settings, or returns null
if is null.
The call timing for the new settings.
A new instance or null if is null..
Creates a for the specified header mutation, or returns null
if is null.
Action to modify the headers to send at the beginning of the call.
A new instance, or null if is null..
Creates a for the specified response metadata handler, or returns null
if is null.
Action to receive response metadata when the call completes.
A new instance, or null if is null..
Creates a for the specified trailing metadata handler, or returns null
if is null.
Action to receive trailing metadata when the call completes.
A new instance, or null if is null..
Creates a for the specified header name and value.
The name of the header to add. Must not be null.
The value of the header to add. Must not be null.
A new instance.
Creates a that will include a field mask in the request, to
limit which fields are returned in the response.
The precise effect on the request is not guaranteed: it may be through a header or a side-channel,
for example. Likewise the effect of combining multiple settings containing field masks is not specified.
The field mask for the request. Must not be null.
A new instance.
Creates a which applies an x-goog-request-params header with the specified
parameter name and value.
The value is URL-encoded; it is expected that is already URL-encoded.
This method is intended to be called from API-specific client libraries; it would be very unusual
for it to be appropriate to call from application code.
The name of the parameter. Must not be null.
The value of the parameter, which may be null. A null value is equivalent to providing an empty string.
A which applies the appropriate header with a single parameter.
Creates a which applies an x-goog-request-params header with the specified
escaped header value.
This method is intended to be called from API-specific client libraries; it would be very unusual
for it to be appropriate to call from application code.
The value of the x-goog-request-params header.
Must be escaped. Must not be null or empty.
A which applies the appropriate header.
Creates a CallSettings which applies an x-goog-request-reason header with the specified reason.
The request reason to specify in the x-goog-request-reason header. Must not be null
A CallSettings which applies the appropriate header.
Helper class defining some common metadata mutation actions.
Removes from all entries with if any.
The metadata set to modify. Must no be null.
The name of entries to override. Must no be null.
Removes from all entries with if any
and adds a single entry with the given name and value.
The metadata set to modify. Must no be null.
The name of entries to override. Must no be null.
The value to associate to a new entry with the given name. Must not be null.
If two or more entries with exist in
they are removed and their values concatenated using and a new entry
is added for the given name, with the resulting concatenated value.
The metadata set to modify. Must not be null.
The name of entries whose values are to be concatenated. Must not be null.
The separator to use for concatenation. Must not be null.
Extension methods for .
All methods accept a null first parameter as valid unless stated otherwise.
The header used to send the project ID used for billing and quotas.
The value should be set through the credential or the client builder,
never explicitly as a header.
This method merges the settings in with those in
, with taking priority.
If both arguments are null, the result is null. If one argument is null,
the other argument is returned. Otherwise, a new object is created with a property-wise
overlay, where null values do not override non-null values.
Any header mutations are combined, however: the mutation from the original is
performed, then the mutation in the overlay.
Original settings. May be null.
Settings to overlay. May be null.
A merged set of call settings, or null if both parameters are null.
Returns a new with the specified cancellation token,
merged with the (optional) original settings specified by .
Original settings. May be null, in which case the returned settings
will only contain the cancellation token.
Cancellation token for the new call settings.
A new set of call settings.
Returns a new with the specified expiration,
merged with the (optional) original settings specified by .
Original settings. May be null, in which case the returned settings
will only contain the expiration.
Expiration to use in the returned settings, possibly as part of a retry. May be null,
in which case any expiration in is not present in the new call settings. If
both this and are null, the return value is null.
A new set of call settings with the specified expiration, or null of both parameters are null.
Returns a new with the specified retry settings,
merged with the (optional) original settings specified by .
Original settings. May be null, in which case the returned settings
will only contain call timing.
Call timing for the new call settings.
This may be null, in which case any retry settings in are
not present in the new call settings. If both this and are null,
the return value is null.
A new set of call settings, or null if both parameters are null.
Returns a new with the specified header,
merged with the (optional) original settings specified by .
Existing headers in settings will not be overritten, that is, if settings
already contains a header for the new value
will be included in that header's set of values, even if it was already present
in settings for the header with the given name.
Original settings. May be null, in which case the returned settings
will only contain the header.
Header name. Must not be null.
Header value. Must not be null.
A new set of call settings including the specified header.
Returns a which will have the specified deadline.
Existing settings. May be null, meaning there are currently no settings.
The deadline for the new settings.
A new with the given deadline.
Returns a which will have the specified timeout.
Existing settings. May be null, meaning there are currently no settings.
The timeout for the new settings.
A new with the given timeout.
Returns a which will have an effective deadline of at least .
If already observes an earlier deadline (with respect to ),
or if is null, the original settings will be returned.
Existing settings. May be null, meaning there are currently no settings.
Deadline to enforce. May be null, meaning there is no deadline to enforce.
The clock to use when computing deadlines. Must not be null.
The call settings to use to observe the given deadline.
Throws if is non-null and has a Retry;
otherwise returns the parameter.
The call settings for the call. May be null.
Transfers settings contained in this into a .
The call settings for the call. May be null.
The clock to use for deadline calculation.
A configured from this .
Method used to check that the headers set by the uer are valid.
Current only checks that the x-goog-user-project
header is not set
directly by the user. It should be set either through the credential or the client builder.
The user set headers.
Method used to check if a header set by the uer is valid.
Current only checks that the x-goog-user-project
header is not set
directly by the user. It should be set either through the credential or the client builder.
The user set header.
Extension methods for .
Shuts down a channel semi-synchronously. This method initially calls
if the channel implements (e.g. in the case of )
and then calls . This method does not wait for the task
to complete, but observes any exceptions (whether the task is faulted or canceled), optionally logging
them to .
The channel to shut down.
An optional logger to record any errors during asynchronous shutdown.
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.
Creates a channel pool which will use the given service metadata to determine scopes and the use of self-signed JWTs.
The metadata for the service that this pool will be used with. Must not be null.
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.
A task which will complete when all the (current) channels have been shut down.
Returns a channel from this pool, creating a new one if there is no channel
already associated with .
The specified channel options are applied, but only those options.
The gRPC implementation to use. Must not be null.
The universe domain configured for the service client,
to validate against the one configured for the credential. Must not be null.
The endpoint to connect to. Must not be null.
The channel options to include. May be null.
A channel for the specified endpoint.
Asynchronously returns a channel from this pool, creating a new one if there is no channel
already associated with .
The specified channel options are applied, but only those options.
The gRPC implementation to use. Must not be null.
The universe domain configured for the service client,
to validate against the one configured for the credential. Must not be null.
The endpoint to connect to. Must not be null.
The channel options to include. May be null.
A cancellation token for the operation.
A task representing the asynchronous operation. The value of the completed
task will be channel for the specified endpoint.
Base class for API-specific builders.
The type of client created by this builder.
The default gRPC options.
The metadata associated with the service that this client will make requests to.
The universe domain to connect to, or null to use the default universe domain .
is used to build the endpoint to connect to, unless
is set, in which case will be used without further modification.
If default credentials or one of , or
is used, should be:
- The same as if has been set.
- otherwise.
Effective, and known, universe domain to connect to.
Will be null if is not set and there's nothing to gain
from defaulting to . For instance,
if has been set, which is self contained, we really don't know
the universe we are in, and we really don't care.
This will be:
- The value of if set.
- null if is set.
- null if both and one of the non options is used.
- otherwise.
Note that we don't validate here that the builder properties are set in a valid combination.
is to be called from and after
has been called.
The endpoint to connect to, or null to use the default endpoint.
If is set, its value will take preference over that built using .
The logger to include in the client, if any.
The scopes to use, or null to use the default scopes.
The channel credentials to use, or null if credentials are being provided in a different way.
The path to the credentials file to use, or null if credentials are being provided in a different way.
The credentials to use as a JSON string, or null if credentials are being provided in a different way.
The credentials to use as a , or null if credentials are being provided in
a different way. Note that unlike and ,
settings for , and self-signed JWTs will be applied to this
credential (creating a new one), in the same way as for application default credentials and credentials
specified using or .
The credentials to use in "raw" form, for conversion into channel credentials. No other settings
(e.g. or ) are applied to these credentials.
The token access method to use, or null if credentials are being provided in a different way.
The call invoker to use, or null to create the call invoker when the client is built.
A custom user agent to specify in the channel metadata, or null if no custom user agent is required.
The gRPC implementation to use, or null to use the default implementation.
The emulator detection policy to apply when building a client. Derived classes which support
emulators should create public properties which delegate to this one. The default value is
.
An API key to use as an alternative to a full credential.
This is protected as not all APIs support API keys. APIs which support API keys
should declare a new public property (also called ApiKey) in the concrete client builder class,
and ensure they call to potentially specify the API key header
via CallSettings.
The GCP project ID that should be used for quota and billing purposes.
May be null.
Any custom channel options to merge with the default options.
If an option specified both here and in the default options, the custom option
will take priority. This property may be null (the default) in which case the default
options are used.
Returns the channel created last time any of the -related methods
were called, or null
if the last-created client did not require channel creation.
If a channel is obtained from a channel pool, this does not count as channel creation.
This property is useful when multiple clients are created and the calling code wishes to clean up
resources associated with the channel.
Returns the service endpoint taking into account and .
Override this property in a concrete builder type if an endpoint may be customized further.
Creates a new instance with no explicit settings.
This takes the value of from .
The metadata for the service that the client will be used with. Must not be null.
Copies common settings from the specified builder into this one. This is a shallow copy.
The other client type
The builder to copy from.
Copies common settings from the specified builder, expecting that any settings around
credentials and endpoints will be set by the caller, along with any client-specific settings.
Emulator detection is not copied, to avoid infinite recursion when building.
Returns the effective settings for this builder, taking into account API keys and any other properties
which may require additional settings (typically via ).
This method only needs to be called if the concrete builder type knows that the settings may
need to be modified (e.g. if the API supports API keys). It should typically be called as
GetEffectiveSettings(Settings?.Clone()).
The concrete settings type, derived from , with a
parameterless constructor that can be used to construct a new default instance.
A clone of the existing settings specified in the concrete builder type. May be null.
The appropriate effective settings for this builder, or null if no settings have been
provided and no other properties require additional settings. Note that clone operations are provided
on a per-concrete-type basis, so this method must accept already-cloned settings.
Validates that the builder is in a consistent state for building. For example, it's invalid to call
on an instance which has both JSON credentials and a credentials path specified.
The builder is in an invalid state.
Performs basic emulator detection and validation based on the given environment variables.
This method is expected to be called by a derived class that supports emulators, in order to perform the common
work of checking whether the emulator is configured in the environment.
If the emulator should not be used, either due to being disabled in or
the appropriate environment variables not being set, this method returns null.
Otherwise, a dictionary is returned mapping every value in to the value in
the environment. Any missing, empty or whitespace-only values are mapped to a null reference in the returned dictionary, but
the entry will still be present (so callers can use an indexer with the returned dictionary for every environment variable passed in).
The configuration is inconsistent, e.g. due to some environment variables
being set but not all the required ones, or any environment variables being set in a production-only environment.
Required emulator environment variables.
All emulator environment variables.
The provider used to retrieve environment variables. This is used to faciliate testing, and defaults
to using .
A key/value mapping of the emulator environment variables to their values, or null if the emulator should not be used.
Validates that at most one of the given values is not null.
The message if the condition is violated.
The values to check for nullity.
More than one value is null.
Validates that if is not null, then every value in is null.
The message if the condition is violated.
The value controlling whether or not any other value can be non-null.
The values checked for non-nullity if is non-null.
Creates a call invoker synchronously. Override this method in a concrete builder type if more
call invoker mechanisms are supported.
This implementation calls if no call invoker is specified.
Creates a call invoker asynchronously. Override this method in a concrete builder type if more
call invoker mechanisms are supported.
This implementation calls if no call
invoker is specified.
Obtains channel credentials synchronously. Override this method in a concrete builder type if more
credential mechanisms are supported.
Obtains channel credentials asynchronously. Override this method in a concrete builder type if more
credential mechanisms are supported.
Obtains channel credentials synchronously if they've been supplied in a ready-to-go fashion.
This avoids code duplication in the sync and async paths.
Returns null if the credentials aren't available.
Returns the channel pool to use when no other options are specified. This method is not called unless
returns true, so if a channel pool is unavailable, override that property
to return false and throw an exception from this method.
Returns the effective for this builder,
using the property if that is set, or the appropriate fallback adapter
for otherwise.
Returns the options to use when creating a channel, taking
into account.
The options to use when creating a channel.
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 quota project, scopes, credentials or token access method have been specified and
if UseJwtAccessWithScopes flag matches the flag in ChannelPool.
Derived classes should override this property if there are other reasons why the channel pool should not be used.
Returns whether or not self-signed JWTs will be used over OAuth tokens when OAuth scopes are explicitly set.
In the base implementation, this defaults to true. Subclasses may add code in their own constructors
to make the default effectively false, however.
Builds the resulting client.
Populates properties based on those set via dependency injection.
If gRPC adapters are configured in , the first one that supports
the will be used.
Credentials are only requested from dependency injection if they are not already set
via any of , ,
, ,
or .
If credentials are requested, they are tried in the following order:
- ChannelCredentials
- ICredential
- GoogleCredential
The service provider to request dependencies from.
Builds the resulting client asynchronously.
Populates properties supplied via dependency injection, then builds a client.
The service provider to request dependencies from. Must not be null.
An API client configured from this builder.
Populates properties supplied via dependency injection, then builds a client asynchronously.
The service provider to request dependencies from. Must not be null.
A token to cancel the operation.
An API client configured from this builder.
Returns a as created by
for the specified endpoint and credentials, using the gRPC channel options from
.
This is only useful in very specific situations where a known channel is required;
and its async equivalent are more usually useful.
This implementation sets the property, and so should
any overriding implementations.
The endpoint of the channel.
The channel credentials.
The channel created by the gRPC adapter.
Common helper code shared by clients. This class is primarily expected to be used from generated code.
Call settings specifying headers for the client version (x-goog-api-client) and
optionally the API version (x-goog-api-version).
Constructs a helper from the given settings.
Behavior is undefined if settings are changed after construction.
This constructor will be removed in the next major version of GAX.
The service settings.
The logger to use for API calls
Constructs a helper from the given options. See the properties in
for validity constraints.
The options for the helper.
The clock used for timing of retries and deadlines. This is never
null; if the clock isn't specified in the settings, this property
will return the instance.
The scheduler used for delays of retries. This is never
null; if the scheduler isn't specified in the settings, this property
will return the instance.
The logger used by this instance, or null if it does not perform logging.
Builds an given suitable underlying async and sync calls.
Request type, which must be a protobuf message.
Response type, which must be a protobuf message.
The underlying method name, for diagnostic purposes.
The underlying synchronous gRPC call.
The underlying asynchronous gRPC call.
The default method call settings.
An API call to proxy to the RPC calls
Builds an given a suitable underlying server streaming call.
Request type, which must be a protobuf message.
Response type, which must be a protobuf message.
The underlying method name, for diagnostic purposes.
The underlying gRPC server streaming call.
The default method call settings.
An API call to proxy to the RPC calls
Builds an given a suitable underlying duplex call.
The underlying method name, for diagnostic purposes.
Request type, which must be a protobuf message.
Response type, which must be a protobuf message.
The underlying gRPC duplex streaming call.
The default method call settings.
The default streaming settings.
An API call to proxy to the RPC calls
Builds an given a suitable underlying client streaming call.
Request type, which must be a protobuf message.
Response type, which must be a protobuf message.
The underlying method name, for diagnostic purposes.
The underlying gRPC client streaming call.
The default method call settings.
The default streaming settings.
An API call to proxy to the RPC calls
The options used to construct a .
This class is designed to allow additional configuration to be introduced without
either overloading the ClientHelper constructor or making breaking changes.
The service settings. This must not be null when the options
are passed to the constructor.
The logger to use, if any. This may be null.
The API version to send in the x-goog-api-version header, if any. This may be null.
Base class for the client-side streaming RPC methods. This wraps the
request stream in a buffer, allowing multiple requests to be written without waiting for them
to be transmitted.
To avoid memory leaks, users must dispose of gRPC streams.
RPC request type
RPC response type
The underlying gRPC client streaming call.
Warning: DO NOT USE GrpcCall.RequestStream at all if using
, ,
, or .
Doing so will cause conflict with the write-buffer used within the [Try]WriteAsync methods.
Writes a message to the stream, if there is enough space in the buffer and
hasn't already been called. The same write options will be used as for the previous message.
The message to write.
null if the message queue is full or the stream has already been completed;
otherwise, a which will complete when the message has been written to the stream.
Writes a message to the stream, if there is enough space in the buffer and
hasn't already been called. The same write options will be used as for the previous message.
The message to write.
There isn't enough space left in the buffer,
or has already been called.
A which will complete when the message has been written to the stream.
Writes a message to the stream, if there is enough space in the buffer and
hasn't already been called.
The message to write.
The write options to use for this message.
null if the message queue is full or the stream has already been completed.
Writes a message to the stream, if there is enough space in the buffer and
hasn't already been called.
The message to write.
The write options to use for this message.
There isn't enough space left in the buffer,
or has already been called.
A which will complete when the message has been written to the stream.
Completes the stream when all buffered messages have been sent.
Only the first call to this method on any instance will have any effect;
subsequent calls will return null.
A which will complete when the stream has finished being completed;
or null if this method has already been called.
Completes the stream when all buffered messages have been sent. This method can only be called
once, and further messages cannot be written after it has been called.
This method has already been called.
A which will complete when the stream has finished being completed.
Disposes of the underlying gRPC call. There is no need to dispose of both the wrapper
and the underlying call; it's typically simpler to dispose of the wrapper with a
using
statement as the wrapper is returned by client libraries.
The default implementation just calls Dispose on the result of .
Asynchronous call result. This task will only complete after
has already been called.
A task representing the asynchronous operation. The result of the completed task
will be the RPC response.
Settings for client streaming.
Configure settings for client streaming.
The capacity of the write buffer, that locally buffers streaming requests
before they are sent to the server.
Caches the application default channel credentials for an individual service, applying a specified set of scopes when required.
Lazily-created task to retrieve the default application channel credentials. Once completed, this
task can be used whenever channel credentials are required. The returned task always runs in the
thread pool, so its result can be used synchronously from synchronous methods without risk of deadlock.
The same channel credentials are used by all pools. The field is initialized in the constructor, as it uses
_scopes, and you can't refer to an instance field within an instance field initializer.
Creates a cache which will apply the specified scopes to the default application credentials
if they require any.
The metadata of the service the credentials will be used with. Must not be null.
Non-generic static class just for generic type inference, to make it easier to construct instances
of .
The type of the expected source request. Specifying this explicitly
is usually sufficient to allow type inference to work for generic methods within this class.
Creates a
to forward a single unary call to a method in an existing .
The type of the source response, i.e. the response we expect to return
to the caller at the end of the method.
The type of the target request, i.e. the request we'll forward on
to .
The type of the target response, i.e. the response we expect to be
returned by .
The original invoker that will handle the request.
The full name (as reported by )
of the method to forward.
The target method to call on .
A delegate to convert source requests to target requests.
A delegate to convert target responses to source responses, with
additional context being provided from the original source request.
A call invoker forwarding the specified call.
A which forwards specific calls to an existing invoker,
transforming the requests and responses as necessary.
It would be cleaner to write an interceptor for this functionality, but that doesn't allow for the request/response types to be changed.
Currently, only unary methods are supported, and only a single method can be forwarded. Any
other method results in an with a status code of .
The type parameters of this class would make it hard to support multiple calls, which is why the factory
class method has a return type of rather than the concrete class: we may implement
multi-method support via composition of multiple call invokers.
Keeps record of channel affinity and active streams.
This class is thread-safe.
Call invoker which can fan calls out to multiple underlying channels
based on request properties.
Initializes a new instance.
The metadata for the service that this call invoker will be used with. Must not be null.
Target of the underlying grpc channels. Must not be null.
Credentials to secure the underlying grpc channels. Must not be null.
Channel options to be used by the underlying grpc channels. Must not be null.
The API config to apply. Must not be null.
The adapter to use to create channels. Must not be null.
Invokes a client streaming call asynchronously.
In client streaming scenario, client sends a stream of requests and server responds with a single response.
Invokes a duplex streaming call asynchronously.
In duplex streaming scenario, client sends a stream of requests and server responds with a stream of responses.
The response stream is completely independent and both side can be sending messages at the same time.
Invokes a server streaming call asynchronously.
In server streaming scenario, client sends on request and server responds with a stream of responses.
Invokes a simple remote call asynchronously.
Invokes a simple remote call in a blocking fashion.
Shuts down the all channels in the underlying channel pool cleanly. It is strongly
recommended to shutdown all previously created channels before exiting from the process.
Returns a deep clone of the internal list of channel references.
This method should only be used in tests.
Returns a deep clone of the internal dictionary of channel references by affinity key.
This method should only be used in tests.
A pool of GCP call invokers for the same service, but with potentially different endpoints and/or channel options.
Each endpoint/options pair has a single . All call invokers created by this pool use
default application credentials. This class is thread-safe.
Creates a call invoker pool which will use the given service metadata to determine scopes
and self-signed JWT support.
The metadata for the service that this pool will be used with. Must not be null.
Shuts down all the open channels of all currently-allocated call invokers asynchronously. This does not prevent
the call invoker pool from being used later on, but the currently-allocated call invokers will not be reused.
A task which will complete when all the (current) channels have been shut down.
Returns a call invoker from this pool, creating a new one if there is no call invoker
already associated with and .
The universe domain configured for the service client,
to validate against the one configured for the credential. Must not be null.
The endpoint to connect to. Must not be null.
The options to use for each channel created by the call invoker. May be null.
The API configuration used to determine channel keys. Must not be null.
The gRPC adapter to use to create call invokers. Must not be null.
A call invoker for the specified endpoint.
Asynchronously returns a call invoker from this pool, creating a new one if there is no call invoker
already associated with and .
The universe domain configured for the service client,
to validate against the one configured for the credential. Must not be null.
The endpoint to connect to. Must not be null.
The options to use for each channel created by the call invoker. May be null.
The API configuration used to determine channel keys. Must not be null.
The gRPC adapter to use to create call invokers. Must not be null.
The cancellation token to cancel the operation.
A task representing the asynchronous operation. The value of the completed
task will be a call invoker for the specified endpoint.
Returns a call invoker from this pool, creating a new one if there is no call invoker
already associated with and .
The endpoint to connect to. Must not be null.
The options to use for each channel created by the call invoker. May be null.
The API configuration used to determine channel keys. Must not be null.
The gRPC adapter to use to create call invokers. Must not be null.
A call invoker for the specified endpoint.
Asynchronously returns a call invoker from this pool, creating a new one if there is no call invoker
already associated with and .
The endpoint to connect to. Must not be null.
The options to use for each channel created by the call invoker. May be null.
The API configuration used to determine channel keys. Must not be null.
The gRPC adapter to use to create call invokers. Must not be null.
A task representing the asynchronous operation. The value of the completed
task will be a call invoker for the specified endpoint.
A wrapper class for handling post process for server streaming responses.
The type representing the request.
The type representing the response.
Holder for reflection information generated from grpc_gcp.proto
File descriptor for grpc_gcp.proto
Field number for the "channel_pool" field.
The channel pool configurations.
Field number for the "method" field.
The method configurations.
Field number for the "max_size" field.
The max number of channels in the pool.
Field number for the "idle_timeout" field.
The idle timeout (seconds) of channels without bound affinity sessions.
Field number for the "max_concurrent_streams_low_watermark" field.
The low watermark of max number of concurrent streams in a channel.
New channel will be created once it get hit, until we reach the max size
of the channel pool.
Field number for the "name" field.
A fully qualified name of a gRPC method, or a wildcard pattern ending
with .*, such as foo.bar.A, foo.bar.*. Method configs are evaluated
sequentially, and the first one takes precedence.
Field number for the "affinity" field.
The channel affinity configurations.
Field number for the "command" field.
The affinity command applies on the selected gRPC methods.
Field number for the "affinity_key" field.
The field path of the affinity key in the request/response message.
For example: "f.a", "f.b.d", etc.
Container for nested types declared in the AffinityConfig message type.
The annotated method will be required to be bound to an existing session
to execute the RPC. The corresponding <affinity_key_field_path> will be
used to find the affinity key from the request message.
The annotated method will establish the channel affinity with the channel
which is used to execute the RPC. The corresponding
<affinity_key_field_path> will be used to find the affinity key from the
response message.
The annotated method will remove the channel affinity with the channel
which is used to execute the RPC. The corresponding
<affinity_key_field_path> will be used to find the affinity key from the
request message.
Extension methods for Google credential universe domain validation.
Returns a channel credential based on , that will validate its own universe domain
against .
The Google credential to build the channel credentials from. Must not be null.
The universe domain to validate against. Must not be null.
should result in the same value as this.
Interoperability layer for different gRPC transports. Concrete subclasses are
, and .
This is an abstract class with all concrete subclasses internal, and internal abstract methods
to prevent instantiation elsewhere. (The abstraction itself may change over time.)
The lazily-evaluated adapter to use for services with ApiTransports.Grpc.
Returns whether or not this adapter supports the specified service.
The service metadata. Must not be null.
true if this adapter supports the given service; false otherwise.
Returns a fallback provider suitable for the given API
The descriptor of the API. Must not be null.
A suitable GrpcAdapter for the given API, preferring the use of the binary gRPC transport where available.
Creates a channel for the given endpoint, using the given credentials and options.
The metadata for the service. Must not be null.
The endpoint to connect to. Must not be null.
The channel credentials to use. Must not be null.
The channel options to use. Must not be null.
A channel for the specified settings.
Creates a channel for the given endpoint, using the given credentials and options. All parameters
are pre-validated to be non-null.
The endpoint to connect to. Will not be null.
The channel credentials to use. Will not be null.
The channel options to use. Will not be null.
A channel for the specified settings.
Portable abstraction of channel options
An empty set of channel options.
If non-null, explicitly enables or disables service configuration resolution.
If non-null, explicitly specifies the keep-alive period for the channel.
This specifies how often a keep-alive request is sent.
If non-null, explicitly specifies the keep-alive timeout for the channel.
This specifies how long gRPC will wait for a keep-alive response before
assuming the channel is no longer valid, and closing it.
If non-null, explicitly specifies the primary user agent for the channel.
If non-null, explicitly specifies the maximum size in bytes that can be sent from the client, per request.
If non-null, explicitly specifies the maximum size in bytes that can be received from the client, per response.
Immutable list of custom options. This is never null, but may be empty.
Returns a new instance with the same options as this one, but with set to
.
The new primary user agent. Must not be null.
The new options.
Returns a new instance with the same options as this one, but with set to
.
The new option for enabling service config resolution.
The new options.
Returns a new instance with the same options as this one, but with set to
.
The new keep-alive time.
The new options.
Returns a new instance with the same options as this one, but with set to
.
The new keep-alive timeout.
The new options.
Returns a new instance with the same options as this one, but with set to
.
The new maximum send message size, in bytes.
The new options.
Returns a new instance with the same options as this one, but with set to
.
The new maximum receive message size, in bytes.
The new options.
Returns a new instance with the same options as this one, but with a new integer-valued
at the end of .
The name of the new custom option. Must not be null.
The value of the new custom option.
The new options.
Returns a new instance with the same options as this one, but with a new string-valued
at the end of .
The name of the new custom option. Must not be null.
The value of the new custom option. Must not be null.
The new options.
Returns a new instance with the same options as this one, but with a new integer-valued
at the end of .
The additional custom option to include. Must not be null.
The new options.
Returns a new object, with options from this object merged with .
If an option is non-null in both objects, the one from takes priority.
The overlaid options. Must not be null.
The new merged options.
A custom option, with a name and a value of either a 32-bit integer or a string.
Possible types of value within a custom option.
Channel option with an integer value.
Channel option with a string value.
Name of the option. This is never null.
Value of the option, for string options. This is never null for string options, and always
null for other options.
Value of the option, for integer options, or 0 for other options.
The type of value represented within this option.
Creates a custom integer option.
The name of the option. Must not be null.
Value of the option.
Creates a custom string option.
The name of the option. Must not be null.
Value of the option. Must not be null.
Implementation of for Grpc.Core.
Prevent lazy type initialization.
Returns the singleton instance of this class.
Creates a delegate that can be used to create a channel in . We do this once, via
expression trees, to avoid having to perform a lot of reflection every time we create a channel.
Converts a (defined in Google.Api.Gax.Grpc) into a list
of ChannelOption (defined in Grpc.Core). This is generic to allow the simple use of delegates
for option factories. Internal for testing.
The options to convert. Must not be null.
Factory delegate to create an option from an integer value
Factory delegate to create an option from an integer value
Implementation of for Grpc.Net.Client.
Returns the default instance of this class.
Returns a new instance based on this one, but with the additional options configurer specified.
The options configurer is called after creating the from
other settings, but before creating the .
An optional configuration delegate to apply to instances of
before they are provided to a , after any configuration applied by this adapter. May be null,
in which case a new instance is returned but with the same option configurer as this one.
A new adapter based on this one, but with an additional channel options configuration action.
An asynchronous sequence of resources, obtained lazily via API operations which retrieve a page at a time.
The API request type.
The API response type. Each response contains a page of resources.
The resource type contained within the response.
Creates a new lazily-evaluated asynchronous sequence from the given API call, initial request, and call settings.
The request is cloned each time the sequence is evaluated.
The API call made each time a page is required.
The initial request.
The settings to apply to each API call.
Class to effectively perform SelectMany on the pages, extracting resources.
This allows us to avoid taking a dependency on System.Linq.Async.
An asynchronous sequence of API responses, each containing a page of resources.
The API request type.
The API response type.
The resource type contained within the response.
A sequence of resources, obtained lazily via API operations which retrieve a page at a time.
The API request type.
The API response type. Each response contains a page of resources.
The resource type contained within the response.
Creates a new lazily-evaluated sequence from the given API call, initial request, and call settings.
The request is cloned each time the sequence is evaluated.
The API call made each time a page is required.
The initial request.
The settings to apply to each API call.
Helper methods to build a instance.
See the
Monitored Resource List for details.
An instance of a "global" resource, with
set to "global", and an empty set of .
A new instance is returned with each call, as the returned object is mutable.
Builds a from the auto-detected
platform, using .
This call can block for up to 1 second.
A instance, populated most suitably for the given platform.
Builds a from the auto-detected
platform, using .
A task, the result of which will be a instance,
populated most suitably for the given platform.
Builds a suitable instance, given
information.
Use or to build a
from auto-detected platform information.
information, usually auto-detected.
A instance, populated most suitably for the given platform.
A request for a page-streaming operation.
A token indicating the page to return. This is obtained from an earlier response,
via .
The maximum number of elements to return in the response.
A response in a page-streaming operation.
The type of resource contained in the response.
The token to set in the when requesting
the next page of results.
Utility methods for protobufs. This is deliberately internal; these methods may be effectively exposed
in specific public classes, but only in a way that allows different use cases that happen to have the
same behavior now to be separated later. Code here is also a reasonable candidate to be exposed in Google.Protobuf.
Determines whether the given value is a protobuf default value - i.e. if it's
null, an empty string, a zero value (integer, numeric or enum) or an empty byte string.
Formats a value in a way that is suitable for a header, URL path segment (after URL-encoding), or query parameter. The value
is effectively formatted the same way it is in the JSON representation. The return value of this
method is only guaranteed for single primitive values - not repeated fields, maps, or messages.
A string representation of the given value, or null if the value is null
Format a well-known type value, and if it has quotes around it, remove them. (For some well-known types, e.g. FloatValue,
it will sometimes be formatted as a JSON string and sometimes not.)
Determines whether the given message descriptor represents a well-known type.
This is an internal method in Google.Protobuf; we might consider exposing it at some point.
Returns the original name of the given enum value, or null if the value is unknown.
Methods to convert ChannelCredentials and CallCredentials into AsyncAuthInterceptors,
so we can ask them to populate auth headers.
Returns the async auth interceptor derived from the given channel credentials, or null
if the channel credentials don't involve an interceptor.
The channel credentials to convert.
Returns the async auth interceptor derived from the given channel credentials, or null
if the channel credentials don't involve an interceptor.
The channel credentials to convert.
Representation of a pattern within a google.api.http option, such as "/v4/{parent=projects/*/tenants/*}/jobs".
The pattern is parsed once, and placeholders (such as "parent" in the above) are interpreted as fields within
a protobuf request message. The pattern can then be formatted later within the context of a request.
The path segments - these are *not* slash-separated segments, but instead they're based on fields. So
/xyz/{a}/abc/{b} would contain four segments, "/xyz/", "{a}", "/abc/", "{b}".
Attempts to format the path with respect to the given request,
returning the formatted segment or null if formatting failed due to the request data.
Names of the fields of the top-level message that are bound by this pattern.
Formats this segment in the context of the given request,
returning null if the data in the request means that the path doesn't match.
A path segment that matches a field in the request.
The separator between the field path and the pattern.
The separator between fields within the field path.
The field path, used to determine which fields should be populated as query parameters.
Each element of the field path is the JSON name of the field, as it would be used
in a query parameter.
Creates a segment representing the given field text, with respect to
the given request descriptor.
The text of the field segment, e.g. "{foo=*}"
The descriptor within which to find the field.
A path segment that is just based on a literal string. This always
succeeds, producing the same result every time.
A transcoder for an HttpRule, including any additional bindings, which are
applied in turn until a match is found with a result.
Creates a transcoder for the given method (named only for error messages) with the specified
request message descriptor and HttpRule. See AIP-127 (https://google.aip.dev/127) and the proto comments
for google.api.HttpRule (https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L44-L312)
Name of the method, used only for diagnostic purposes.
The descriptor for the message request type
The HttpRule that the new transcoder should represent, excluding any additional bindings.
Returns the transcoding result from the first matching HttpRule, or
null if no rules match.
A transcoder for a single rule, ignoring additional bindings.
Attempts to use this rule to transcode the given request.
The request to transcode. Must not be null.
The result of transcoding, or null if the rule did not match.
A field that might be transcoded as a query parameter.
A delegate which accepts the original request message, and returns the parent of _field,
or null if the field isn't present in the request.
Simple state tracker to indicate when a server-streamed response is "done".
We expect that:
- The overall response is an array
- The later JSON parser will perform fuller validation (e.g. this code
won't spot that [{[{]}}] is broken.
Note that this is mutable rather than us creating a new instance on each "push"
of a character, because:
- It's not *just* a simple state machine: we count open/close object/arrays
- We could make it a struct containing those counters and a detailed state enum,
it's not obvious that would be easier to use.
Pushes a single character, returning the appropriate action to be taken next.
Before we first see [
We stay in this state, only accepting whitespace or [ until we see the first [
Between response objects.
In this state, we only accept:
- Whitespace (stay in this state)
- Comma (stay in this state)
- { (move to Normal state)
- ] (move to AfterTopArray state)
Not in a string token, but somewhere within the top-level array.
In a string token, but not directly after a backslash.
In a string token, directly after a backslash.
(The only permitted characters to follow this are double-quote, backslash, slash, b, f, n, r, t or u.
Although u should then be followed by four hex digits, we don't enforce that.)
We have detected an error. This is unrecoverable.
After the final ]
We can only accept whitespace after this.
The action that should be taken by the caller immediately after a call to .
We've received the closing ] at the end of the top level array.
There should be no further non-whitespace characters.
We've received the closing } at the end of an object directly
within the top level array. Remember that pushed } and parse
everything remembered since the last response was parsed.
We've detected an error. Signal this to the higher-level caller.
We don't have details of the failure.
Continue reading data and pushing it with the method.
The character that has been pushed does not need to be retained.
Remember the pushed character (because it's part of a top-level object).
Continue reading data and pushing it with the method.
An IAsyncStreamReader implementation that reads an array of messages
from HTTP stream as they arrive in (partial) JSON chunks.
Type of proto messages in the stream
Task which will return a reader containing the data.
Converter to parse each individual JSON object in the response stream.
Cancellation context used to observe deadlines, original cancellation tokens from call options,
and gRPC-method-based cancellation.
Responses which have already been parsed, and are ready to return to the caller.
The current response that we're building up.
The buffer we use when reading from the text reader.
We don't need to actually preserve state between calls,
as we process the whole read buffer on each call, but
this avoids allocating multiple times.
(As an alternative, we could allocate a smaller amount on the stack
each time.)
Keeps track of our state within the stream of JSON responses.
This is not a full JSON tokenizer, but has just enough logic to
recognize "we've reached the end of one response," or "we've reached
the end of all responses," or "something's gone wrong". (It doesn't
try to perform complete validation, but spots unexpected data between
elements etc.)
Will be set to true when all responses have been read from the stream.
(Any responses queued in should still be returned.)
This does *not* mean we've reached the end of the data, however.
Set to true when we've reached the end of the data. If this happens without
being true, that causes an error.
Set to non-null on any failure.
Creates a new instance which will read data from the TextReader provided by
, and convert each object within a top-level JSON array
into a response using .
A task to provide text reader returning partial JSON chunks
A function to transform a well-formed JSON object into the proto message.
The cancellation context for the RPC.
Called when we don't have a queued response and haven't reached a terminal state (error or completed).
Returns the value from the original task provided in , or throws
if was cancelled before the task completed.
Disposes of the underlying reader, in a fire-and-forget manner.
The reader may not yet be available, so a task is attached to the reader-providing
task to dispose of the reader when it becomes available.
The returned by this implementation will already be completed.
Disposes of the underlying reader, in a fire-and-forget manner, as well as the
cancellation context.
The reader may not yet be available, so a task is attached to the reader-providing
task to dispose of the reader when it becomes available.
In the functions to obtain the TResponse
and the of the call are two different functions.
The function to obtain the response is async, but the function to obtain the
is not.
For being able to surface error details in we need to be
able to call which is an async method,
and thus cannot be done, without blocking, on the sync function that obtains the
in the .
So we need to make async content reading part of sending the call and not part of
building the TResponse.
This class is just a convenient wrapper for passing together the
and its read response.
Create an RPC status from the HTTP status code, attempting to parse the
content as an Rpc.Status if the HTTP status indicates a failure.
Holder for reflection information generated from response_metadata.proto
File descriptor for response_metadata.proto
This message defines the error schema for Google's JSON HTTP APIs.
Field number for the "error" field.
The actual error payload. The nested message structure is for backward
compatibility with [Google API Client
Libraries](https://developers.google.com/api-client-library). It also
makes the error more readable to developers.
Container for nested types declared in the Error message type.
Deprecated. This message is only used by error format v1.
This message has the same semantics as `google.rpc.Status`. It uses HTTP
status code instead of gRPC status code. It has extra fields `status` and
`errors` for backward compatibility with [Google API Client
Libraries](https://developers.google.com/api-client-library).
Field number for the "code" field.
The HTTP status code that corresponds to `google.rpc.Status.code`.
Field number for the "message" field.
This corresponds to `google.rpc.Status.message`.
Field number for the "errors" field.
Deprecated. This field is only used by error format v1.
Field number for the "status" field.
This is the enum version for `google.rpc.Status.code`.
Field number for the "details" field.
This corresponds to `google.rpc.Status.details`, but
we represent each element as a Struct instead of an Any so that
we can definitely parse the outer JSON. We then convert each struct back into
JSON and attempt to parse it as an Any, ignoring values that have type URLs
corresponding to messages we're not aware of.
CallInvoker implementation which uses regular HTTP requests with JSON payloads.
This just delegates back to the that it wraps.
gRPC "channel" that really uses REST/JSON over HTTP to make RPCs.
The channel is aware of which APIs it supports, so that it's able to perform the
appropriate request translation.
Equivalent to .
Equivalent to .
Creates an HTTP request, adds headers from CallOptions, and sends the request.
The type of request
The RPC being called; used to convert the request
Override for the endpoint, if any
The gRPC call options, used for headers and cancellation
The RPC request
The option indicating at what point the method should complete,
The cancellation token for the RPC.
within HTTP response processing
Implementation of that uses HTTP/1.1 and JSON,
but via a gRPC .
Returns the default gRPC adapter for the REST transport.
Converts an HTTP status code into the corresponding gRPC status code.
Note that there is not a 1:1 correspondence between status code; multiple
HTTP status codes can map to the same gRPC status code.
The HTTP status code to convert
The converted gRPC status code.
Class to convert between proto request/response messages and HTTP request/response messages.
(Details of request transcoding are mostly in ,
but they are abstracted by this class.)
The service-qualified method name, as used by gRPC, e.g. "/google.somepackage.SomeService/SomeMethod"
Returns the name by which gRPC will refer to the given proto method,
e.g. "/google.somepackage.SomeService/SomeMethod".
Creates a representation from the given protobuf method representation.
The metadata for the API that this method is part of.
The protobuf method to represent.
The JSON parser to use when parsing requests.
A representation of the method that can be used to handle HTTP requests/responses,
or null if the method is currently not supported in REGAPIC.
Parses the response and converts it into the protobuf response type.
Parses a single JSON object as a .
The response type to parse; this is expected to match the method output type.
Represents a set of methods all expected to be accessible via the same host.
(The host itself is not part of the state of this class.)
TODO: Do we need this class, or could we keep the dictionary directly in RestChannel?
Returns the corresponding to .
The method is not supported by REGAPIC, or is not in the service at all.
Centralized handling of cancellation differentiation between time-outs
and explicit cancellation, as well as disposal of any CancellationTokenSource objects.
This also allows the RPC to be cancelled explicitly (separate from any cancellation tokens
previously created); this is expected to be used via
etc.
While it would be nice for this to be fully testable via IClock, the
CancellationTokenSource constructor that starts a timer isn't really testable anyway,
so everything is done with the system clock instead.
Creates an instance using the given cancellation token source for deadlines and the given
call cancellation token. This is only present for test purposes.
Creates a cancellation context from the given call options.
The name of the RPC, used to report exceptions.
The call options used for this RPC call, optionally including
a deadline and cancellation token.
The options contain a deadline that has already elapsed
Combines with the RPC's cancellation tokens, and waits for
the task provided by to complete, converting any
into an with an appropriate status (DeadlineExceeded or Cancelled depending
on which token was responsible for the original exception).
A function which returns a task to await.
An additional cancellation token, defaulting to "no extra cancellation token,
just use the RPC's cancellation tokens".
A task which will complete when the provided task completes.
Combines with the RPC's cancellation tokens, and waits for
the task provided by to complete, converting any
into an with an appropriate status (DeadlineExceeded or Cancelled depending
on which token was responsible for the original exception).
The type of the task provided by .
A function which returns a task to await.
An additional cancellation token, defaulting to "no extra cancellation token,
just use the RPC's cancellation tokens".
A task which will complete when the provided task completes.
Cancels the overall RPC. This call is ignored if the context has already been disposed.
Disposes of the resources used by this context. After this method returns,
the context cannot be used: further calls, including ,
will throw .
The result of transcoding a protobuf request using an HttpRule.
This is produced by .
Merges the uri path and the query string parameters, escaping them.
Ignores the possibility that the path can already have parameters or contain an anchor (`#`).
This method is visible for testing; production code should generally call
instead.
The URI path merged with the encoded query string parameters
An attempt at a retriable operation. Use
or to create a sequence of attempts that follow the specified settings.
The 1-based number of this attempt. If this is equal to for the settings
used to create this attempt, will always return false.
The time that will be used to sleep or delay in and .
This has already had jitter applied to it.
Returns a sequence of retry attempts. The sequence has elements, and calling
on the last attempt will always return false. This overload assumes no deadline,
and so does not require a clock.
The retry settings to create a sequence for. Must not be null.
The scheduler to use for delays.
An override value to allow an initial backoff which is not the same
as . This is typically to allow an "immediate first retry".
Returns a sequence of retry attempts. The sequence has elements, and calling
on the last attempt will always return false.
The retry settings to create a sequence for. Must not be null.
The scheduler to use for delays.
The overall deadline for the operation.
The clock to use to compare the current time with the deadline.
An override value to allow an initial backoff which is not the same
as . This is typically to allow an "immediate first retry".
Indicates whether the operation should be retried when the given exception has been thrown.
This will return false if the exception indicates that the operation shouldn't be retried,
or the maximum number of attempts has been reached, or the next backoff would exceed the overall
deadline. (It is assumed that or
will be called immediately afterwards.)
The exception thrown by the retriable operation.
true if the operation should be retried; false otherwise.
Synchronously sleeps for a period of .
The cancellation token to apply to the sleep operation.
Asynchronously delays for a period of .
The cancellation token to apply to the delay operation.
Settings for retrying RPCs.
The maximum number of attempts to make. Always greater than or equal to 1.
The backoff time between the first attempt and the first retry. Always non-negative.
The maximum backoff time between retries. Always non-negative.
The multiplier to apply to the backoff on each iteration; always greater than or equal to 1.0.
As an example, a multiplier of 2.0 with an initial backoff of 0.1s on an RPC would then apply
a backoff of 0.2s, then 0.4s until it is capped by .
A predicate to determine whether or not a particular exception should cause the operation to be retried.
Usually this is simply a matter of checking the status codes. This is never null.
The delay jitter to apply for delays, defaulting to . This is never null.
"Jitter" is used to introduce randomness into the pattern of delays. This is to avoid multiple
clients performing the same delay pattern starting at the same point in time,
leading to higher-than-necessary contention. The default jitter simply takes each maximum delay
and returns an actual delay which is a uniformly random value between 0 and the maximum. This
is good enough for most applications, but makes precise testing difficult.
Creates a new instance with the given settings.
The maximum number of attempts to make. Must be positive.
The backoff after the initial failure. Must be non-negative.
The maximum backoff. Must be at least .
The multiplier to apply to backoff times. Must be at least 1.0.
The predicate to use to check whether an error should be retried. Must not be null.
The jitter to use on each backoff. Must not be null.
Returns a using the specified maximum number of attempts and a constant backoff.
Jitter is still applied to each backoff, but the "base" value of the backoff is always .
The maximum number of attempts to make. Must be positive.
The backoff after each failure. Must be non-negative.
The predicate to use to check whether an error should be retried. Must not be null.
The jitter to use on each backoff. May be null, in which case is used.
A retry with constant backoff.
Returns a using the specified maximum number of attempts and an exponential backoff.
The maximum number of attempts to make. Must be positive.
The backoff after the initial failure. Must be non-negative.
The maximum backoff. Must be at least .
The multiplier to apply to backoff times. Must be at least 1.0.
The predicate to use to check whether an error should be retried. Must not be null.
The jitter to use on each backoff. May be null, in which case is used.
A retry with exponential backoff.
Provides a mechanism for applying jitter to delays between retries.
See the property for more information.
Returns the actual delay to use given a maximum available delay.
The maximum delay provided by the backoff settings
The delay to use before retrying.
The default jitter which returns a uniformly distributed random delay between 0 and
the specified maximum.
A jitter which simply returns the specified maximum delay.
Creates a retry filter based on status codes.
The status codes to retry. Must not be null.
A retry filter based on status codes.
Creates a retry filter based on status codes.
The status codes to retry. Must not be null.
A retry filter based on status codes.
Works out the next backoff from the current one, based on the multiplier and maximum.
The current backoff to use as a basis for the next one.
The next backoff to use, which is always at least and at most .
Collects the explicit routing header extraction instructions and
extracts the routing header value from a specific request
using these instructions.
This class is immutable.
The individual pattern extractors present in this extractor. These
are only present for chaining purposes while building up the full
extractor. (If we ever move to a builder pattern, we could remove these.)
These are retained in declaration order.
The parameter extractors, created from .
These are used at execution time to extract the values for parameters.
Create a new RoutingHeaderExtractor with no patterns. (This cannot be used
to extract headers; new instances must be created with
which provides patterns to use to extract values.)
Returns a string representation of the given value, suitable for including in a routing header.
(This method does not perform URI encoding; it is expected that the result of this method will either be
used in , or as an argument to
.)
The value to format. May be null.
The formatted value, or null if is null.
Returns a new instance with the same parameter extractors as this one, with an additional one specified as arguments.
The extractions follow the "last successfully matched wins" rule for
conflict resolution when there are multiple extractions for the same parameter name.
(See `google/api/routing.proto` for further details.) If multiple parameters
with different names are present, the extracted header will contain them in the order
in which they have been added with this method, based on the first occurrence of
each parameter name.
The name of the parameter in the routing header.
The regular expression (in string form) used to extract the value of the parameter.
Must have exactly one capturing group (in addition to the implicit "group 0" which captures the whole match).
A function to call on each request, to determine the string to extract the header value from.
The parameter must not be null, but may return null.
Extracts the routing header value to apply based on a request.
A request to extract the routing header parameters and values from
The value to use for the routing header. This may contain multiple &-separated parameters.
An extractor for a single parameter, which may check multiple patterns to extract a value.
Creates an instance based on the single-pattern extractors, in the order in which they are
declared. They will be *applied* in reverse order. It is assumed that all pattern extractors
are for the same parameter name.
Extracts the value from the request and returns it in a form ready to be included in the
header
An extractor for a single pattern, used one option within a .
Extracts the value from the request by matching it against the pattern,
returning the the key/value pair in the form key=value, after URI-escaping the value.
Utility extension methods to make it easier to retrieve extended error information from an .
Retrieves the message containing extended error information
from the trailers in an , if present.
The RPC exception to retrieve details from. Must not be null.
The message specified in the exception, or null
if there is no such information.
Retrieves the message containing extended error information
from the trailers in an , if present.
The RPC exception to retrieve details from. Must not be null.
The message specified in the exception, or null
if there is no such information.
Retrieves the message containing extended error information
from the trailers in an , if present.
The RPC exception to retrieve details from. Must not be null.
The message specified in the exception, or null
if there is no such information.
Retrieves the error details of type from the
message associated with an , if any.
The message type to decode from within the error details.
The RPC exception to retrieve details from. Must not be null.
Base class for server streaming RPC methods. This wraps an underlying call returned by gRPC,
in order to provide a wrapper for the async response stream, allowing users to take advantage
of await foreach
support from C# 8 onwards.
To avoid memory leaks, users must dispose of gRPC streams.
Additionally, you are strongly advised to read the whole response stream, even if the data
is not required - this avoids effectively cancelling the call.
RPC streaming response type
The underlying gRPC duplex streaming call.
Async stream to read streaming responses, exposed as an async sequence.
The default implementation will use to extract a response
stream, and adapt it to .
If this method is called more than once, all the returned enumerators will be enumerating over the
same underlying response stream, which may cause confusion. Additionally, the sequence returned by
this method can only be iterated over a single time. Attempting to iterate more than once will cause
an .
Disposes of the underlying gRPC call. There is no need to dispose of both the wrapper
and the underlying call; it's typically simpler to dispose of the wrapper with a
using
statement as the wrapper is returned by client libraries.
The default implementation just calls Dispose on the result of .
Provides metadata about a single service within an API.
Often most of these aspects will be the same across multiple services,
but they can be specified with different values in the original proto, so
they are specified individually here. This class is expected to be constructed
with a single instance per service; equality is by simple identity.
The protobuf service descriptor for this service. This is never null.
The name of the service within the API, e.g. "Subscriber". This is never null or empty.
The default endpoint for the service. This may be null, if a service has no default endpoint.
The default endpoint is an endpoint in the default universe domain.
The template to build and endpoint for the service taking into account a custom universe domain,
for instance "storage.{0}".
May be null, in which case no universe domain dependent endpoint may be built for the service.
The default scopes for the service. This will never be null, but may be empty.
This will never contain any null references.
This will never change after construction.
Whether this service supports scoped JWT access (in which case
this is preferred by default over OAuth tokens).
The metadata for the API this is part of. This is never null.
The transports supported by this service.
Constructs a new instance for a given service.
The protobuf descriptor for the service.
The default endpoint to connect to.
The default scopes for the service. Must not be null, and must not contain any null elements. May be empty.
Whether the service supports scoped JWTs as credentials.
The transports supported by this service.
The metadata for this API, including all of the services expected to be available at the same endpoint, and all associated protos.
Common settings for all services.
Constructs a new service settings base object with a default version header, unset call settings and
unset clock.
Constructs a new service settings base object by cloning the settings from an existing one.
The existing settings object to clone settings from. Must not be null.
A builder for x-goog-api-client version headers. Additional library versions can be appended via this property.
End-users should almost never need to use this property; it is primarily for use in Google libraries which provide
a higher level abstraction over the generated client libraries.
If not null, that are applied to every RPC performed by the client.
If null or unset, RPC default settings will be used for all settings.
If not null, the clock used to calculate RPC deadlines. If null or unset, the is used.
This is primarily only to be set for testing.
In production code generally leave this unset to use the .
If not null, the scheduler used for delays between operations (e.g. for retry).
If null or unset, the is used.
This is primarily only to be set for testing.
In production code generally leave this unset to use the .
An optional gRPC interceptor to perform arbitrary interception tasks (such as logging) on gRPC calls.
Note that this property is not used by code generated before August 2nd 2018: only packages created
on or after that date are aware of this property.
Returns a task which can be cancelled by the given cancellation token, but otherwise observes the original
task's state. This does *not* cancel any work that the original task was doing, and should be used carefully.
Returns a task which can be cancelled by the given cancellation token, but otherwise observes the original
task's state. This does *not* cancel any work that the original task was doing, and should be used carefully.
Extension methods for dependency injection.
Adds a singleton to the given service collection
as the preferred implementation,
using the default instance with any additional options configured via .
Before executing the specified action, the
is set to the provider. This enables logging, for example.
The service collection to add the adapter to.
The configuration action to perform on each
when it is used by the adapter to construct a channel. May be null, in which case this method only sets the
service provider.
The same service collection reference, for method chaining.
Adds a singleton to the given service collection
as the preferred implementation,
such that any created uses the service provider from
created this service collection. This enables logging, for example.
The service collection to add the adapter to.
The same service collection reference, for method chaining.
Adds a singleton to the given service collection
as the preferred implementation.
The service collection to add the adapter to.
The same service collection reference, for method chaining.
Adds a singleton to the given service collection
as the preferred implementation.
The service collection to add the adapter to.
The same service collection reference, for method chaining.