Esempio n. 1
0
 public KafkaProducerFactory(KafkaOptions kafkaOptions)
 {
     _kafkaOptions = kafkaOptions;
     Logger        = NullLogger <KafkaProducerFactory <TKey, TValue> > .Instance;
 }
Esempio n. 2
0
 public static IServiceCollection AddKafkaBus(this IServiceCollection serviceCollection, KafkaOptions options, ILoggerFactory loggerFactory, params Assembly[] eventHandlersAssemblies)
 {
     serviceCollection.AddSingleton(typeof(IKafkaProducerFactory <,>), typeof(KafkaProducerFactory <,>));
     serviceCollection.AddTransient <KafkaOptions>(provider => options);
     serviceCollection.AddSingleton <ISubscriptionManager, SubscriptionManager>();
     serviceCollection.AddSingleton <IKafkaBus>(provider =>
     {
         var kafkaBus = new KafkaBus(provider.GetService <KafkaOptions>(),
                                     provider.GetService <ISubscriptionManager>(),
                                     provider.GetService <IntegrationEventHandlerFactory>());
         kafkaBus.Logger = loggerFactory.CreateLogger <KafkaBus>();
         return(kafkaBus);
     });
     serviceCollection.AddSingleton <IntegrationEventHandlerFactory>(provider => (t) => provider.GetService(t));
     serviceCollection.RegisterGenericType(typeof(IIntegrationEventHandler <>), ServiceLifetime.Transient, eventHandlersAssemblies);
     serviceCollection.RegisterAssembly(typeof(IDynamicIntegrationEventHandler), ServiceLifetime.Transient, eventHandlersAssemblies);
     serviceCollection.AddSingleton <IIntegrationEventAggregation, IntegrationEventAggregation>();
     return(serviceCollection);
 }