public static IAlohaBuilder AddMongo(this IAlohaBuilder builder, string sectionName = SectionName, Type seederType = null, bool registerConventions = true) { if (string.IsNullOrWhiteSpace(sectionName)) { sectionName = SectionName; } var mongoOptions = builder.GetOptions <MongoDbOptions>(sectionName); return(builder.AddMongo(mongoOptions, seederType, registerConventions)); }
public static IAlohaBuilder AddAmazonKinesis(this IAlohaBuilder builder, string sectionName = SectionName) { var options = builder.GetOptions <AmazonKinesisOptions>(sectionName); builder.Services.AddSingleton(options); builder.Services.AddSingleton <IAmazonKinesisClient, AmazonKinesisClient>(); builder.Services.AddSingleton <IStreamPublisher, AmazonKinesisPublisher>(); return(builder); }
public static IAlohaBuilder AddAmazonSQS(this IAlohaBuilder builder, string sectionName = SectionName) { builder.Services.AddSingleton <ICorrelationContextAccessor, CorrelationContextAccessor>(); builder.Services.AddTransient <IAmazonSQSClient, AmazonSQSClient>(); builder.Services.AddScoped <IConventions, MessageConventions>(); builder.Services.AddScoped <IConventionsProvider, ConventionsProvider>(); builder.Services.AddScoped <IBusPublisher, AmazonSQSPublisher>(); builder.Services.AddScoped <IBusConsumer, AmazonSQSConsumer>(); builder.Services.AddSingleton <IAlohaSerializer, NewtonsoftJsonAlohaSerializer>(); var options = builder.GetOptions <AmazonSQSOptions>(sectionName); builder.Services.AddSingleton(options); return(builder); }
public static IAlohaBuilder AddRabbitMq(this IAlohaBuilder builder, string sectionName = SectionName, Action <ConnectionFactory> connectionFactoryConfigurator = null) { builder.Services.AddSingleton <IContextProvider, ContextProvider>(); //builder.Services.AddSingleton<ICorrelationContextAccessor>(new CorrelationContextAccessor()); //builder.Services.AddSingleton<IMessagePropertiesAccessor>(new MessagePropertiesAccessor()); builder.Services.AddSingleton <IConventionsBuilder, ConventionsBuilder>(); builder.Services.AddSingleton <IConventionsProvider, ConventionsProvider>(); builder.Services.AddSingleton <IConventionsRegistry, ConventionsRegistry>(); builder.Services.AddSingleton <IRabbitMqSerializer, NewtonsoftJsonRabbitMqSerializer>(); builder.Services.AddSingleton <IRabbitMqClient, RabbitMqClient>(); builder.Services.AddSingleton <IBusPublisher, RabbitMqPublisher>(); builder.Services.AddSingleton <IBusSubscriber, RabbitMqSubscriber>(); builder.Services.AddSingleton <IRabbitMqPluginsExecutor, RabbitMqPluginsExecutor>(); builder.Services.AddTransient <RabbitMqExchangeInitializer>(); builder.Services.AddHostedService <RabbitMqHostedService>(); builder.AddInitializer <RabbitMqExchangeInitializer>(); var options = builder.GetOptions <RabbitMqOptions>(sectionName); builder.Services.AddSingleton(options); var connectionFactory = new ConnectionFactory { Port = options.Port, VirtualHost = options.VirtualHost, UserName = options.Username, Password = options.Password, //RequestedHeartbeat = options.RequestedHeartbeat, //RequestedConnectionTimeout = options.RequestedConnectionTimeout, //SocketReadTimeout = options.SocketReadTimeout, //SocketWriteTimeout = options.SocketWriteTimeout, //RequestedChannelMax = options.RequestedChannelMax, //RequestedFrameMax = options.RequestedFrameMax, //UseBackgroundThreadsForIO = options.UseBackgroundThreadsForIO, DispatchConsumersAsync = true, //ContinuationTimeout = options.ContinuationTimeout, //HandshakeContinuationTimeout = options.HandshakeContinuationTimeout, //NetworkRecoveryInterval = options.NetworkRecoveryInterval, }; connectionFactoryConfigurator?.Invoke(connectionFactory); var connection = connectionFactory.CreateConnection(options.HostNames, options.ConnectionName); builder.Services.AddSingleton(connection); return(builder); }
public static IAlohaBuilder AddAmazonS3(this IAlohaBuilder builder, string sectionName = SectionName) { var options = builder.GetOptions <AmazonS3Options>(sectionName); builder.Services.AddSingleton(options); IAmazonS3 amazonS3 = new Amazon.S3.AmazonS3Client( new BasicAWSCredentials(options.AccessKey, options.SecretKey), new AmazonS3Config { ServiceURL = options.ServiceUrl }); builder.Services.AddSingleton(amazonS3); builder.Services.AddSingleton <IStorageClient, AmazonS3Client>(); return(builder); }
public static IAlohaBuilder AddRabbitMq(this IAlohaBuilder builder, string sectionName = SectionName, Action <ConnectionFactory> connectionFactoryConfigurator = null) { builder.Services.AddSingleton <IContextProvider, ContextProvider>(); builder.Services.AddSingleton <ICorrelationContextAccessor, CorrelationContextAccessor>(); //builder.Services.AddSingleton<IMessagePropertiesAccessor>(new MessagePropertiesAccessor()); builder.Services.AddSingleton <IConventionsBuilder, ConventionsBuilder>(); builder.Services.AddSingleton <IConventionsProvider, ConventionsProvider>(); builder.Services.AddSingleton <IConventionsRegistry, ConventionsRegistry>(); builder.Services.AddSingleton <IRabbitMqSerializer, NewtonsoftJsonRabbitMqSerializer>(); builder.Services.AddSingleton <IRabbitMqClient, RabbitMqClient>(); builder.Services.AddSingleton <IBusPublisher, RabbitMqPublisher>(); builder.Services.AddSingleton <IBusSubscriber, RabbitMqSubscriber>(); builder.Services.AddSingleton <IRabbitMqPluginsExecutor, RabbitMqPluginsExecutor>(); builder.Services.AddSingleton <RabbitMqExchangeInitializer>(); builder.Services.AddSingleton <RabbitMqHostedService>(); builder.AddInitializer <RabbitMqExchangeInitializer>(); var options = builder.GetOptions <RabbitMqOptions>(sectionName); builder.Services.AddSingleton(options); var connectionFactory = new ConnectionFactory { Port = options.Port, VirtualHost = options.VirtualHost, UserName = options.Username, Password = options.Password, DispatchConsumersAsync = true }; connectionFactoryConfigurator?.Invoke(connectionFactory); var connection = connectionFactory.CreateConnection(options.HostNames, options.ConnectionName); builder.Services.AddSingleton(connection); return(builder); }