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

public static class ServiceCollectionExtensions

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

Provides extension methods to configure dependency injection with PubSub.

Inheritance

object > ServiceCollectionExtensions

Namespace

Microsoft.Extensions.DependencyInjection

Assembly

Google.Cloud.PubSub.V1.dll

Methods

AddPublisherClient(IServiceCollection, TopicName)

public static IServiceCollection AddPublisherClient(this IServiceCollection services, TopicName topicName)

Adds a singleton PublisherClient associated with the specified TopicName, using default settings to the IServiceCollection.

Parameters
Name Description
services IServiceCollection

The IServiceCollection to add the singleton client to.

topicName TopicName

The TopicName to publish messages to. Must not be null.

Returns
Type Description
IServiceCollection

The updated IServiceCollection, for method chaining.

AddPublisherClient(IServiceCollection, Action<PublisherClientBuilder>)

public static IServiceCollection AddPublisherClient(this IServiceCollection services, Action<PublisherClientBuilder> action)

Adds a singleton PublisherClient to the IServiceCollection as customized by the action.

Parameters
Name Description
services IServiceCollection

The IServiceCollection to add the singleton client to.

action ActionPublisherClientBuilder

An action delegate to invoke on the PublisherClientBuilder for configuring the PublisherClient. This is invoked before services are used. Must not be null and at-least TopicName must be set.

Returns
Type Description
IServiceCollection

The updated IServiceCollection, for method chaining.

AddPublisherClient(IServiceCollection, Action<IServiceProvider, PublisherClientBuilder>)

public static IServiceCollection AddPublisherClient(this IServiceCollection services, Action<IServiceProvider, PublisherClientBuilder> action)

Adds a singleton PublisherClient to the IServiceCollection as customized by the action.

Parameters
Name Description
services IServiceCollection

The IServiceCollection to add the singleton client to.

action ActionIServiceProviderPublisherClientBuilder

An action delegate to invoke on the PublisherClientBuilder for configuring the PublisherClient. This is invoked before services are used. Must not be null and at-least TopicName must be set.

Returns
Type Description
IServiceCollection

The updated IServiceCollection, for method chaining.

AddPublisherServiceApiClient(IServiceCollection, Action<PublisherServiceApiClientBuilder>)

public static IServiceCollection AddPublisherServiceApiClient(this IServiceCollection services, Action<PublisherServiceApiClientBuilder> action = null)

Adds a singleton PublisherServiceApiClient to services.

Parameters
Name Description
services IServiceCollection

The service collection to add the client to. The services are used to configure the client when requested.

action ActionPublisherServiceApiClientBuilder

An optional action to invoke on the client builder. This is invoked before services from services are used.

Returns
Type Description
IServiceCollection

AddPublisherServiceApiClient(IServiceCollection, Action<IServiceProvider, PublisherServiceApiClientBuilder>)

public static IServiceCollection AddPublisherServiceApiClient(this IServiceCollection services, Action<IServiceProvider, PublisherServiceApiClientBuilder> action)

Adds a singleton PublisherServiceApiClient to services.

Parameters
Name Description
services IServiceCollection

The service collection to add the client to. The services are used to configure the client when requested.

action ActionIServiceProviderPublisherServiceApiClientBuilder

An optional action to invoke on the client builder. This is invoked before services from services are used.

Returns
Type Description
IServiceCollection

AddSchemaServiceClient(IServiceCollection, Action<SchemaServiceClientBuilder>)

public static IServiceCollection AddSchemaServiceClient(this IServiceCollection services, Action<SchemaServiceClientBuilder> action = null)

Adds a singleton SchemaServiceClient to services.

Parameters
Name Description
services IServiceCollection

The service collection to add the client to. The services are used to configure the client when requested.

action ActionSchemaServiceClientBuilder

An optional action to invoke on the client builder. This is invoked before services from services are used.

Returns
Type Description
IServiceCollection

AddSchemaServiceClient(IServiceCollection, Action<IServiceProvider, SchemaServiceClientBuilder>)

public static IServiceCollection AddSchemaServiceClient(this IServiceCollection services, Action<IServiceProvider, SchemaServiceClientBuilder> action)

Adds a singleton SchemaServiceClient to services.

Parameters
Name Description
services IServiceCollection

The service collection to add the client to. The services are used to configure the client when requested.

action ActionIServiceProviderSchemaServiceClientBuilder

An optional action to invoke on the client builder. This is invoked before services from services are used.

Returns
Type Description
IServiceCollection

AddSubscriberClient(IServiceCollection, SubscriptionName)

public static IServiceCollection AddSubscriberClient(this IServiceCollection services, SubscriptionName subscriptionName)

Adds a singleton SubscriberClient associated with the specified SubscriptionName, using default settings to the IServiceCollection.

Parameters
Name Description
services IServiceCollection

The IServiceCollection to add the singleton client to.

subscriptionName SubscriptionName

The SubscriptionName to receive messages from. Must not be null.

Returns
Type Description
IServiceCollection

The updated IServiceCollection, for method chaining.

AddSubscriberClient(IServiceCollection, Action<SubscriberClientBuilder>)

public static IServiceCollection AddSubscriberClient(this IServiceCollection services, Action<SubscriberClientBuilder> action)

Adds a singleton SubscriberClient to the IServiceCollection as customized by the action.

Parameters
Name Description
services IServiceCollection

The IServiceCollection to add the singleton client to.

action ActionSubscriberClientBuilder

An action to invoke on the SubscriberClientBuilder for configuring the SubscriberClient. This is invoked before services are used. Must not be null and at-least SubscriptionName must be set.

Returns
Type Description
IServiceCollection

The updated IServiceCollection, for method chaining.

AddSubscriberClient(IServiceCollection, Action<IServiceProvider, SubscriberClientBuilder>)

public static IServiceCollection AddSubscriberClient(this IServiceCollection services, Action<IServiceProvider, SubscriberClientBuilder> action)

Adds a singleton SubscriberClient to the IServiceCollection as customized by the action.

Parameters
Name Description
services IServiceCollection

The IServiceCollection to add the singleton client to.

action ActionIServiceProviderSubscriberClientBuilder

An action to invoke on the SubscriberClientBuilder for configuring the SubscriberClient. This is invoked before services are used. Must not be null and at-least SubscriptionName must be set.

Returns
Type Description
IServiceCollection

The updated IServiceCollection, for method chaining.

AddSubscriberServiceApiClient(IServiceCollection, Action<SubscriberServiceApiClientBuilder>)

public static IServiceCollection AddSubscriberServiceApiClient(this IServiceCollection services, Action<SubscriberServiceApiClientBuilder> action = null)

Adds a singleton SubscriberServiceApiClient to services.

Parameters
Name Description
services IServiceCollection

The service collection to add the client to. The services are used to configure the client when requested.

action ActionSubscriberServiceApiClientBuilder

An optional action to invoke on the client builder. This is invoked before services from services are used.

Returns
Type Description
IServiceCollection

AddSubscriberServiceApiClient(IServiceCollection, Action<IServiceProvider, SubscriberServiceApiClientBuilder>)

public static IServiceCollection AddSubscriberServiceApiClient(this IServiceCollection services, Action<IServiceProvider, SubscriberServiceApiClientBuilder> action)

Adds a singleton SubscriberServiceApiClient to services.

Parameters
Name Description
services IServiceCollection

The service collection to add the client to. The services are used to configure the client when requested.

action ActionIServiceProviderSubscriberServiceApiClientBuilder

An optional action to invoke on the client builder. This is invoked before services from services are used.

Returns
Type Description
IServiceCollection