public async Task InitNetworkProtocol() { var(getFromAPi, _) = _api.ForNetwork; if (_kafkaConfig.Enabled) { _kafkaPublisher = new KafkaPublisher( _kafkaConfig, new PubSubModelMapper(), new AvroMapper(getFromAPi.BlockTree), getFromAPi.LogManager); getFromAPi.Publishers.Add(_kafkaPublisher); IPublisher kafkaPublisher = await PrepareKafkaProducer(); getFromAPi.Publishers.Add(kafkaPublisher); getFromAPi.DisposeStack.Push(kafkaPublisher); } }
private async Task <IPublisher> PrepareKafkaProducer() { var(getFromAPi, _) = _api.ForNetwork; PubSubModelMapper pubSubModelMapper = new PubSubModelMapper(); AvroMapper avroMapper = new AvroMapper(getFromAPi.BlockTree); KafkaPublisher kafkaPublisher = new KafkaPublisher( _kafkaConfig, pubSubModelMapper, avroMapper, getFromAPi.LogManager); await kafkaPublisher.InitAsync().ContinueWith(x => { if (x.IsFaulted && _logger.IsError) { _logger.Error("Error during Kafka initialization", x.Exception); } }); return(kafkaPublisher); }