Table of Contents

Class ServiceCollectionExtensions

Namespace
Savvyio.Extensions.DependencyInjection.SimpleQueueService
Assembly
Savvyio.Extensions.DependencyInjection.SimpleQueueService.dll

Extension methods for the IServiceCollection interface.

public static class ServiceCollectionExtensions
Inheritance
ServiceCollectionExtensions

Examples

Register Amazon SQS command queues and SNS event buses in the DI container with AddAmazonCommandQueue and AddAmazonEventBus. Both methods configure AWS credentials and resource settings.

using System;
using Amazon;
using Amazon.Runtime;
using Microsoft.Extensions.DependencyInjection;
using Savvyio.Extensions.DependencyInjection;
using Savvyio.Extensions.DependencyInjection.SimpleQueueService;

namespace ExampleApp;

public static class AmazonRegistration
{
    public static IServiceCollection Configure(IServiceCollection services)
    {
        services.AddSavvyIO();
        services.AddAmazonCommandQueue(options =>
        {
            options.Credentials = new AnonymousAWSCredentials();
            options.Endpoint = RegionEndpoint.EUWest1;
            options.SourceQueue = new Uri("https://sqs.eu-west-1.amazonaws.com/123456789012/account-commands");
        });
        services.AddAmazonEventBus(options =>
        {
            options.Credentials = new AnonymousAWSCredentials();
            options.Endpoint = RegionEndpoint.EUWest1;
            options.SourceQueue = new Uri("https://sqs.eu-west-1.amazonaws.com/123456789012/account-events");
        });
        return services;
    }
}

Methods

AddAmazonCommandQueue(IServiceCollection, Action<AmazonCommandQueueOptions>, Action<ServiceOptions>)

Adds an AmazonCommandQueue implementation to the specified IServiceCollection.

public static IServiceCollection AddAmazonCommandQueue(this IServiceCollection services, Action<AmazonCommandQueueOptions> awsSetup, Action<ServiceOptions> serviceSetup = null)

Parameters

services IServiceCollection

The IServiceCollection to extend.

awsSetup Action<AmazonCommandQueueOptions>

The AmazonCommandQueueOptions that needs to be configured.

serviceSetup Action<ServiceOptions>

The ServiceOptions which may be configured.

Returns

IServiceCollection

A reference to services so that additional calls can be chained.

Remarks

The implementation will be type forwarded accordingly.

Exceptions

ArgumentNullException

services cannot be null.

AddAmazonCommandQueue<TMarker>(IServiceCollection, Action<AmazonCommandQueueOptions<TMarker>>, Action<ServiceOptions>)

Adds an AmazonCommandQueue<TMarker> implementation to the specified IServiceCollection.

public static IServiceCollection AddAmazonCommandQueue<TMarker>(this IServiceCollection services, Action<AmazonCommandQueueOptions<TMarker>> awsSetup, Action<ServiceOptions> serviceSetup = null)

Parameters

services IServiceCollection

The IServiceCollection to extend.

awsSetup Action<AmazonCommandQueueOptions<TMarker>>

The AmazonCommandQueueOptions<TMarker> that needs to be configured.

serviceSetup Action<ServiceOptions>

The ServiceOptions which may be configured.

Returns

IServiceCollection

A reference to services so that additional calls can be chained.

Type Parameters

TMarker

Remarks

The implementation will be type forwarded accordingly.

Exceptions

ArgumentNullException

services cannot be null.

AddAmazonEventBus(IServiceCollection, Action<AmazonEventBusOptions>, Action<ServiceOptions>)

Adds an AmazonEventBus implementation to the specified IServiceCollection.

public static IServiceCollection AddAmazonEventBus(this IServiceCollection services, Action<AmazonEventBusOptions> awsSetup, Action<ServiceOptions> serviceSetup = null)

Parameters

services IServiceCollection

The IServiceCollection to extend.

awsSetup Action<AmazonEventBusOptions>

The AmazonEventBusOptions that needs to be configured.

serviceSetup Action<ServiceOptions>

The ServiceOptions which may be configured.

Returns

IServiceCollection

A reference to services so that additional calls can be chained.

Remarks

The implementation will be type forwarded accordingly.

Exceptions

ArgumentNullException

services cannot be null.

AddAmazonEventBus<TMarker>(IServiceCollection, Action<AmazonEventBusOptions<TMarker>>, Action<ServiceOptions>)

Adds an AmazonEventBus<TMarker> implementation to the specified IServiceCollection.

public static IServiceCollection AddAmazonEventBus<TMarker>(this IServiceCollection services, Action<AmazonEventBusOptions<TMarker>> awsSetup, Action<ServiceOptions> serviceSetup = null)

Parameters

services IServiceCollection

The IServiceCollection to extend.

awsSetup Action<AmazonEventBusOptions<TMarker>>

The AmazonEventBusOptions<TMarker> that needs to be configured.

serviceSetup Action<ServiceOptions>

The ServiceOptions which may be configured.

Returns

IServiceCollection

A reference to services so that additional calls can be chained.

Type Parameters

TMarker

Remarks

The implementation will be type forwarded accordingly.

Exceptions

ArgumentNullException

services cannot be null.