Cucumber/Cloud/Services/Broker/Implement/Kafka/KafkaService.cs

22 lines
682 B
C#

using Cloud.Services.Broker.Support;
namespace Cloud.Services.Broker.Implement.Kafka
{
public class KafkaService : IBrokerService
{
private readonly KafkaProducer _producer;
private readonly KafkaConsumer _consumer;
public KafkaService(IConfiguration configuration)
{
_producer = new KafkaProducer(configuration);
_consumer = new KafkaConsumer(configuration);
}
public T? Consume<T>(string topic)
where T : IBrokerResponse => _consumer.WaitMessage<T>(topic);
public async Task Produce(Command command)
=> await _producer.ProduceAsync("commands", command);
}
}