public sealed class SubscriberClientImpl : SubscriberClient
Implementation of SubscriberClient.
Namespace
Google.Cloud.PubSub.V1Assembly
Google.Cloud.PubSub.V1.dll
Constructors
SubscriberClientImpl(SubscriptionName, IEnumerable<SubscriberServiceApiClient>, SubscriberClient.Settings, Func<Task>)
public SubscriberClientImpl(SubscriptionName subscriptionName, IEnumerable<SubscriberServiceApiClient> clients, SubscriberClient.Settings settings, Func<Task> shutdown)
Instantiate a SubscriberClientImpl associated with the specified SubscriptionName.
Parameters | |
---|---|
Name | Description |
subscriptionName | SubscriptionName The SubscriptionName to receive messages from. |
clients | System.Collections.Generic.IEnumerable<SubscriberServiceApiClient> The SubscriberServiceApiClients to use in a SubscriberClient. For high performance, these should all use distinct Grpc.Core.Channels. |
settings | SubscriberClient.Settings SubscriberClient.Settings for creating a SubscriberClient. |
shutdown | System.Func<System.Threading.Tasks.Task> Function to call on this SubscriberClientImpl shutdown. |
Properties
SubscriptionName
public override SubscriptionName SubscriptionName { get; }
The associated SubscriptionName.
Property Value | |
---|---|
Type | Description |
SubscriptionName |
Methods
StartAsync(Func<PubsubMessage, CancellationToken, Task<SubscriberClient.Reply>>)
public override Task StartAsync(Func<PubsubMessage, CancellationToken, Task<SubscriberClient.Reply>> handlerAsync)
Starts receiving messages. The returned System.Threading.Tasks.Task completes when either StopAsync(CancellationToken) is called or if an unrecoverable fault occurs. See StopAsync(CancellationToken) for more details. This method cannot be called more than once per SubscriberClient instance.
Parameter | |
---|---|
Name | Description |
handlerAsync | System.Func<PubsubMessage, System.Threading.CancellationToken, System.Threading.Tasks.Task<SubscriberClient.Reply>> The handler function that is passed all received messages. This function may be called on multiple threads concurrently. Return Ack from this function to ACKnowledge this message (implying it won't be received again); or return Nack to Not ACKnowledge this message (implying it will be received again). If this function throws any Exception, then it behaves as if it returned Nack. |
Returns | |
---|---|
Type | Description |
System.Threading.Tasks.Task | A System.Threading.Tasks.Task that completes when the subscriber is stopped, or if an unrecoverable error occurs. |
StopAsync(CancellationToken)
public override Task StopAsync(CancellationToken hardStopToken)
Stop this SubscriberClient. Cancelling hardStopToken
aborts the
clean stop process, and may leave some handled messages un-ACKnowledged.
The returned System.Threading.Tasks.Task completes when all handled messages have been ACKnowledged.
The returned System.Threading.Tasks.Task faults if there is an unrecoverable error with the underlying service.
The returned System.Threading.Tasks.Task cancels if hardStopToken
is cancelled.
Parameter | |
---|---|
Name | Description |
hardStopToken | System.Threading.CancellationToken Cancel this System.Threading.CancellationToken to abort handlers and ACKnowledgement. |
Returns | |
---|---|
Type | Description |
System.Threading.Tasks.Task | A System.Threading.Tasks.Task that completes when all handled messages have been ACKnowledged;
faults on unrecoverable service errors; or cancels if |