Exemple #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);
 }
Exemple #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);
 }
Exemple #3
0
 public RabbitEventBus(
     IObserverUnitContainer observerUnitContainer,
     IRabbitEventBusContainer eventBusContainer,
     string exchange, string routePrefix, int lBCount = 1, bool reenqueue = true, bool persistent = false)
 {
     if (string.IsNullOrEmpty(exchange))
     {
         throw new ArgumentNullException(nameof(exchange));
     }
     if (string.IsNullOrEmpty(routePrefix))
     {
         throw new ArgumentNullException(nameof(routePrefix));
     }
     if (lBCount < 1)
     {
         throw new ArgumentOutOfRangeException($"{nameof(lBCount)} must be greater than 1");
     }
     this.observerUnitContainer = observerUnitContainer;
     Container      = eventBusContainer;
     Exchange       = exchange;
     RoutePrefix    = routePrefix;
     LBCount        = lBCount;
     Persistent     = persistent;
     ConsumerConfig = new ConsumerOptions
     {
         Reenqueue         = reenqueue,
         ErrorQueueSuffix  = "_error",
         MaxReenqueueTimes = 10
     };
 }
Exemple #4
0
 public EventBusContainer(
     IObserverUnitContainer observerUnitContainer,
     IKafkaClient client)
 {
     Client = client;
     this.observerUnitContainer = observerUnitContainer;
 }
Exemple #5
0
 public Task ConfigureObserverUnit(IServiceProvider serviceProvider, IObserverUnitContainer container)
 {
     //container.Register(ObserverUnit<long>.From<Account>(serviceProvider).
     //    Observer<IAccountRep>(DefaultObserverGroup.primary).
     //    Observer<IAccountFlow>(DefaultObserverGroup.primary).
     //    Observer<IAccountDb>(DefaultObserverGroup.secondary));
     return(Task.CompletedTask);
 }
Exemple #6
0
 public EventBusContainer(
     IServiceProvider serviceProvider,
     IObserverUnitContainer observerUnitContainer,
     IRabbitMQClient rabbitMQClient)
 {
     this.serviceProvider       = serviceProvider;
     this.rabbitMQClient        = rabbitMQClient;
     this.observerUnitContainer = observerUnitContainer;
 }
Exemple #7
0
 public EventBusContainer(
     IServiceProvider serviceProvider,
     IObserverUnitContainer observerUnitContainer,
     IKafkaClient client)
 {
     this.serviceProvider = serviceProvider;
     Client = client;
     this.observerUnitContainer = observerUnitContainer;
 }
Exemple #8
0
 public EventBusContainer(
     IServiceProvider serviceProvider,
     IObserverUnitContainer observerUnitContainer,
     IRabbitMQClient rabbitMQClient,
     IOptions <RabbitOptions> rabbitOptions)
 {
     this.serviceProvider       = serviceProvider;
     this.rabbitMQClient        = rabbitMQClient;
     this.observerUnitContainer = observerUnitContainer;
     this.rabbitOptions         = rabbitOptions.Value;
 }
Exemple #9
0
 public RabbitEventBus(
     IServiceProvider serviceProvider,
     IRabbitEventBusContainer eventBusContainer,
     string exchange, string routePrefix, int lBCount = 1, ushort minQos = 100, ushort incQos = 100, ushort maxQos = 300, bool autoAck = false, bool reenqueue = false)
 {
     if (string.IsNullOrEmpty(exchange))
     {
         throw new ArgumentNullException(nameof(exchange));
     }
     if (string.IsNullOrEmpty(routePrefix))
     {
         throw new ArgumentNullException(nameof(routePrefix));
     }
     if (lBCount < 1)
     {
         throw new ArgumentOutOfRangeException($"{nameof(lBCount)} must be greater than 1");
     }
     ServiceProvider       = serviceProvider;
     observerUnitContainer = serviceProvider.GetService <IObserverUnitContainer>();
     Container             = eventBusContainer;
     Exchange              = exchange;
     RoutePrefix           = routePrefix;
     LBCount               = lBCount;
     DefaultConsumerConfig = new BranchOptions
     {
         AutoAck   = autoAck,
         MaxQos    = maxQos,
         MinQos    = minQos,
         IncQos    = incQos,
         Reenqueue = reenqueue
     };
     RouteList = new List <string>();
     if (LBCount == 1)
     {
         RouteList.Add(routePrefix);
     }
     else
     {
         for (int i = 0; i < LBCount; i++)
         {
             RouteList.Add($"{routePrefix }_{ i.ToString()}");
         }
     }
     _CHash = new ConsistentHash(RouteList, lBCount * 10);
 }
Exemple #10
0
 public RabbitEventBus(
     IObserverUnitContainer observerUnitContainer,
     IRabbitEventBusContainer eventBusContainer,
     string exchange, string routePrefix, int lBCount = 1, ushort qos = 5000, bool autoAck = false, bool reenqueue = true, bool persistent = false)
 {
     if (string.IsNullOrEmpty(exchange))
     {
         throw new ArgumentNullException(nameof(exchange));
     }
     if (string.IsNullOrEmpty(routePrefix))
     {
         throw new ArgumentNullException(nameof(routePrefix));
     }
     if (lBCount < 1)
     {
         throw new ArgumentOutOfRangeException($"{nameof(lBCount)} must be greater than 1");
     }
     this.observerUnitContainer = observerUnitContainer;
     Container      = eventBusContainer;
     Exchange       = exchange;
     RoutePrefix    = routePrefix;
     LBCount        = lBCount;
     Persistent     = persistent;
     ConsumerConfig = new ConsumerOptions
     {
         AutoAck   = autoAck,
         Qos       = qos,
         Reenqueue = reenqueue,
     };
     RouteList = new List <string>();
     if (LBCount == 1)
     {
         RouteList.Add(routePrefix);
     }
     else
     {
         for (int i = 0; i < LBCount; i++)
         {
             RouteList.Add($"{routePrefix }_{ i.ToString()}");
         }
     }
     _CHash = new ConsistentHash(RouteList, lBCount * 10);
 }
Exemple #11
0
 public Task ConfigureObserverUnit(IServiceProvider serviceProvider, IObserverUnitContainer followUnitContainer)
 {
     return(Task.CompletedTask);
 }
Exemple #12
0
 public Task ConfigureObserverUnit(IServiceProvider serviceProvider, IObserverUnitContainer followUnitContainer)
 {
     followUnitContainer.Register(ObserverUnit <long> .From <Account>(serviceProvider));
     return(Task.CompletedTask);
 }