Пример #1
0
 public KafkaProducer(
     IKafkaClient client,
     KafkaEventBus publisher)
 {
     this.publisher = publisher;
     this.client    = client;
 }
Пример #2
0
 public EventBusContainer(
     IObserverUnitContainer observerUnitContainer,
     IKafkaClient client)
 {
     Client = client;
     this.observerUnitContainer = observerUnitContainer;
 }
Пример #3
0
 public Worker(
     IKafkaClient <string, string> kafkaClient,
     ILogger <Worker> logger)
 {
     _logger      = logger;
     _kafkaClient = kafkaClient;
 }
Пример #4
0
 public EventBusContainer(
     IServiceProvider serviceProvider,
     IObserverUnitContainer observerUnitContainer,
     IKafkaClient client)
 {
     this.serviceProvider = serviceProvider;
     Client = client;
     this.observerUnitContainer = observerUnitContainer;
 }
Пример #5
0
 public BehaviorService(IKafkaClient kafkaClient)
     : base("/behaviors")
 {
     Post("/", async parameters =>
     {
         Behavior behavior = this.Bind <Behavior>();
         await kafkaClient.ProduceAsync("behaviors", behavior.Id.ToString(), behavior);
     });
 }
Пример #6
0
 public BalancedConsumer(
     IKafkaClient client,
     string group,
     string topic,
     int threads = DefaultNumberOfThreads)
 {
     _client  = client;
     _group   = group;
     _topic   = topic;
     _threads = threads;
 }
Пример #7
0
 public ConsumerRunner(
     IKafkaClient client,
     ILogger <ConsumerRunner> logger,
     KafkaConsumer consumer,
     string topic)
 {
     Client   = client;
     Logger   = logger;
     Consumer = consumer;
     Topic    = topic;
 }
Пример #8
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;
 }
Пример #9
0
 public BalancedConsumer(
     IKafkaClient client,
     string group,
     string topic,
     int threads     = DefaultNumberOfThreads,
     bool autoCommit = true)
 {
     _client     = client;
     _group      = group;
     _topic      = topic;
     _threads    = threads;
     _autoCommit = autoCommit;
 }
Пример #10
0
 public ConsumerRunner(
     IKafkaClient client,
     ILogger <ConsumerRunner> logger,
     KafkaConsumer consumer,
     string topic,
     bool reenqueue = true)
 {
     Client    = client;
     Logger    = logger;
     Consumer  = consumer;
     Topic     = topic;
     Reenqueue = reenqueue;
 }
Пример #11
0
        public ConsumerManager(
            ILogger <ConsumerManager> logger,
            IKafkaClient client,
            IGrainFactory grainFactory,
            IServiceProvider provider)
        {
            this.provider     = provider;
            this.client       = client;
            this.logger       = logger;
            this.grainFactory = grainFactory;

            this.queues = new List <QueueInfo>();
            foreach (var assembly in AssemblyHelper.GetAssemblies(logger))
            {
                foreach (var type in assembly.GetTypes())
                {
                    var attributes = type.GetCustomAttributes(typeof(StreamSubAttribute), false);
                    if (attributes.Length > 0 && attributes.First() is StreamSubAttribute attribute)
                    {
                        foreach (var i in Enumerable.Range(0, attribute.Sharding + 1))
                        {
                            var topic         = i == 0 ? attribute.Name : $"{attribute.Name}_{i}";
                            var interfaceType = type.GetInterfaces().Where(t => typeof(IFlowActor).IsAssignableFrom(t) && !t.IsGenericType && t != typeof(IFlowActor)).FirstOrDefault();
                            var existQueue    = this.queues.SingleOrDefault(q => q.Topic == topic && q.Group == attribute.Group);
                            if (existQueue == default)
                            {
                                this.queues.Add(new QueueInfo
                                {
                                    SubActorType = new List <Type> {
                                        interfaceType
                                    },
                                    Topic = topic,
                                    Group = attribute.Group
                                });
                            }
                            else
                            {
                                existQueue.SubActorType.Add(interfaceType);
                            }
                        }
                    }
                }
            }
        }
Пример #12
0
        public App(IKafkaClient client, IOptions <AppConfig> appConfig, IEnumerable <IEventSink <KafkaMessage> > sinks)
        {
            _sinks = sinks;

            _appConfig = appConfig.Value;

            _kafkaClient = client;

            KafkaMessageStream = Observable.FromEvent <EventHandler <KafkaMessage>, KafkaMessage>(handler =>
            {
                EventHandler <KafkaMessage> kmHandler = (sender, e) => handler(e);

                return(kmHandler);
            },
                                                                                                  x =>
            {
                _kafkaClient.OnMessageReceived += x;
            }, y =>
            {
                _kafkaClient.OnMessageReceived -= y;
            });
        }
Пример #13
0
 public EventStream(IKafkaClient client, string topic)
 {
     this.client = client;
     this.topic  = topic;
 }
Пример #14
0
 public KafkaProducer(IKafkaClient client)
 {
     _producer = new DependentProducerBuilder <string, string>(client.Handle).Build();
 }
Пример #15
0
 public Worker(ILogger <Worker> logger, IKafkaClient <string, string> kafkaClient)
 {
     _logger          = logger;
     this.kafkaClient = kafkaClient;
 }
Пример #16
0
 public SimpleConsumer(IKafkaClient client, string topic, int[] partitions = null)
 {
     _client     = client;
     _topic      = topic;
     _partitions = partitions;
 }
Пример #17
0
 public ProdutoProducer(IKafkaClient <string, string> kafkaClient, ILogger <ProdutoProducer> logger)
 {
     this.kafkaClient = kafkaClient;
     this.logger      = logger;
 }
Пример #18
0
 public Worker(IKafkaClient <string, string> kafkaClient, ILogger <Worker> logger)
 {
     this.kafkaClient = kafkaClient;
     _logger          = logger;
 }
Пример #19
0
 public KafkaController(IKafkaClient kafkaUtil)
 {
     this.kafkaUtil = kafkaUtil;
 }
Пример #20
0
 public KafkaPublisher(IKafkaClient client)
 {
     _client = client;
 }
Пример #21
0
 public EventStreamFactory(IKafkaClient client, IGrainFactory grainFactory)
 {
     this.grainFactory = grainFactory;
     this.client       = client;
 }