Cloud Pub/Sub v1 API - Class SubscriberClientBuilder (3.14.0)

public sealed class SubscriberClientBuilder : ClientBuilderBase<SubscriberClient>

Reference documentation and code samples for the Cloud Pub/Sub v1 API class SubscriberClientBuilder.

Builder class for SubscriberClient to provide simple configuration of credentials, endpoint, client count, subscription settings etc.

Inheritance

object > ClientBuilderBaseSubscriberClient > SubscriberClientBuilder

Namespace

Google.Cloud.PubSub.V1

Assembly

Google.Cloud.PubSub.V1.dll

Constructors

SubscriberClientBuilder()

public SubscriberClientBuilder()

Creates a new instance with default settings. TopicName must be set before calling either Build() or BuildAsync(CancellationToken).

Properties

ApiSettings

public SubscriberServiceApiSettings ApiSettings { get; set; }

The settings to use when creatingSubscriberServiceApiClient instances. Default settings will be used if this is null.

Property Value
Type Description
SubscriberServiceApiSettings

ClientCount

public int? ClientCount { get; set; }

The number of SubscriberServiceApiClients to create and use within a SubscriberClient instance. If this is null, the number of clients created will depend on the processor count.

Property Value
Type Description
int

EmulatorDetection

public EmulatorDetection EmulatorDetection { get; set; }

Specifies how to respond to the presence of emulator environment variables.

Property Value
Type Description
EmulatorDetection
Remarks

This property defaults to None, meaning that environment variables are ignored.

Settings

public SubscriberClient.Settings Settings { get; set; }

Additional settings for batching, message ordering etc. Default settings will be used if this is null.

Property Value
Type Description
SubscriberClientSettings

SubscriptionName

public SubscriptionName SubscriptionName { get; set; }

The name of the subscription that the subscriber subscribes to. This must be non-null by the time Build() or BuildAsync(CancellationToken) is called.

Property Value
Type Description
SubscriptionName

Methods

Build()

public override SubscriberClient Build()

Builds the resulting client.

Returns
Type Description
SubscriberClient
Overrides

BuildAsync(CancellationToken)

public override Task<SubscriberClient> BuildAsync(CancellationToken cancellationToken = default)

Builds the resulting client asynchronously.

Parameter
Name Description
cancellationToken CancellationToken
Returns
Type Description
TaskSubscriberClient
Overrides

GetChannelPool()

protected override ChannelPool GetChannelPool()

Returns the channel pool to use when no other options are specified. This method is not called unless CanUseChannelPool returns true, so if a channel pool is unavailable, override that property to return false and throw an exception from this method.

Returns
Type Description
ChannelPool
Overrides

Validate()

protected override void Validate()

Validates that the builder is in a consistent state for building. For example, it's invalid to call Build() on an instance which has both JSON credentials and a credentials path specified.

Overrides
Exceptions
Type Description
InvalidOperationException

The builder is in an invalid state.