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

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
NameDescription
servicesIServiceCollection

The IServiceCollection to add the singleton client to.

topicNameTopicName

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

Returns
TypeDescription
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
NameDescription
servicesIServiceCollection

The IServiceCollection to add the singleton client to.

actionActionPublisherClientBuilder

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
TypeDescription
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
NameDescription
servicesIServiceCollection

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

actionActionPublisherServiceApiClientBuilder

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

Returns
TypeDescription
IServiceCollection

AddSchemaServiceClient(IServiceCollection, Action<SchemaServiceClientBuilder>)

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

Adds a singleton SchemaServiceClient to services.

Parameters
NameDescription
servicesIServiceCollection

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

actionActionSchemaServiceClientBuilder

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

Returns
TypeDescription
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
NameDescription
servicesIServiceCollection

The IServiceCollection to add the singleton client to.

subscriptionNameSubscriptionName

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

Returns
TypeDescription
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
NameDescription
servicesIServiceCollection

The IServiceCollection to add the singleton client to.

actionActionSubscriberClientBuilder

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
TypeDescription
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
NameDescription
servicesIServiceCollection

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

actionActionSubscriberServiceApiClientBuilder

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

Returns
TypeDescription
IServiceCollection