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 | 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 | Func<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 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 | Func<PubsubMessage, CancellationToken, 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 |
Task | A 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 Task completes when all handled messages have been ACKnowledged.
The returned Task faults if there is an unrecoverable error with the underlying service.
The returned Task cancels if hardStopToken
is cancelled.
Parameter | |
---|---|
Name | Description |
hardStopToken | CancellationToken Cancel this CancellationToken to abort handlers and ACKnowledgement. |
Returns | |
---|---|
Type | Description |
Task | A Task that completes when all handled messages have been ACKnowledged;
faults on unrecoverable service errors; or cancels if |