public static IBrighterBuilder UsePostgreSqlOutbox(
            this IBrighterBuilder brighterBuilder, PostgreSqlOutboxConfiguration configuration, Type connectionProvider = null, ServiceLifetime serviceLifetime = ServiceLifetime.Singleton)
        {
            if (brighterBuilder is null)
            {
                throw new ArgumentNullException($"{nameof(brighterBuilder)} cannot be null.", nameof(brighterBuilder));
            }

            if (configuration is null)
            {
                throw new ArgumentNullException($"{nameof(configuration)} cannot be null.", nameof(configuration));
            }

            brighterBuilder.Services.AddSingleton <PostgreSqlOutboxConfiguration>(configuration);

            if (connectionProvider is object)
            {
                if (!typeof(IPostgreSqlConnectionProvider).IsAssignableFrom(connectionProvider))
                {
                    throw new Exception($"Unable to register provider of type {connectionProvider.GetType().Name}. Class does not implement interface {nameof(IPostgreSqlConnectionProvider)}.");
                }

                brighterBuilder.Services.Add(new ServiceDescriptor(typeof(IPostgreSqlConnectionProvider), connectionProvider, serviceLifetime));
            }

            brighterBuilder.Services.Add(new ServiceDescriptor(typeof(IAmAnOutboxSync <Message>), BuildPostgreSqlOutboxSync, serviceLifetime));

            return(brighterBuilder);
        }
Пример #2
0
        public static IBrighterHandlerBuilder UsePostgreSqlOutbox(
            this IBrighterHandlerBuilder brighterBuilder, PostgreSqlOutboxConfiguration configuration, ServiceLifetime serviceLifetime = ServiceLifetime.Singleton)
        {
            brighterBuilder.Services.AddSingleton <PostgreSqlOutboxConfiguration>(configuration);

            brighterBuilder.Services.Add(new ServiceDescriptor(typeof(IAmAnOutbox <Message>), BuildDynamoDbOutbox, serviceLifetime));
            brighterBuilder.Services.Add(new ServiceDescriptor(typeof(IAmAnOutboxAsync <Message>), BuildDynamoDbOutbox, serviceLifetime));

            return(brighterBuilder);
        }