Ejemplo n.º 1
0
 public KafkaEventBus(
     IServiceProvider serviceProvider,
     IKafkaEventBusContainer eventBusContainer,
     string topic, int lBCount = 1)
 {
     if (string.IsNullOrEmpty(topic))
     {
         throw new ArgumentNullException(nameof(topic));
     }
     if (lBCount < 1)
     {
         throw new ArgumentOutOfRangeException($"{nameof(lBCount)} must be greater than 1");
     }
     ServiceProvider       = serviceProvider;
     observerUnitContainer = serviceProvider.GetService <IObserverUnitContainer>();
     Container             = eventBusContainer;
     Topic   = topic;
     LBCount = lBCount;
     Topics  = new List <string>();
     if (LBCount == 1)
     {
         Topics.Add(Topic);
     }
     else
     {
         for (int i = 0; i < LBCount; i++)
         {
             Topics.Add($"{Topic }_{ i.ToString()}");
         }
     }
     _CHash = new ConsistentHash(Topics, lBCount * 10);
 }
Ejemplo n.º 2
0
 public KafkaEventBus(
     IObserverUnitContainer observerUnitContainer,
     IKafkaEventBusContainer eventBusContainer,
     string topic,
     int lBCount    = 1,
     bool reenqueue = true)
 {
     if (string.IsNullOrEmpty(topic))
     {
         throw new ArgumentNullException(nameof(topic));
     }
     if (lBCount < 1)
     {
         throw new ArgumentOutOfRangeException($"{nameof(lBCount)} must be greater than 1");
     }
     this.observerUnitContainer = observerUnitContainer;
     Container = eventBusContainer;
     Topic     = topic;
     LBCount   = lBCount;
     Reenqueue = reenqueue;
     Topics    = new List <string>();
     if (LBCount == 1)
     {
         Topics.Add(Topic);
     }
     else
     {
         for (int i = 0; i < LBCount; i++)
         {
             Topics.Add($"{Topic }_{ i.ToString()}");
         }
     }
     _CHash = new ConsistentHash(Topics, lBCount * 10);
 }
Ejemplo n.º 3
0
 public ConsumerManager(
     ILogger <ConsumerManager> logger,
     IKafkaClient client,
     IGrainFactory grainFactory,
     IServiceProvider provider,
     IKafkaEventBusContainer kafkaEventBusContainer)
 {
     this.provider = provider;
     this.client   = client;
     this.logger   = logger;
     this.kafkaEventBusContainer = kafkaEventBusContainer;
     this.grainFactory           = grainFactory;
 }