Code cleanup

This commit is contained in:
Andrea Cavalli 2022-09-22 16:26:55 +02:00
parent b322400d87
commit 2b2e690da4
3 changed files with 10 additions and 7 deletions

View File

@ -4,6 +4,7 @@ import it.tdlight.reactiveapi.Event.ClientBoundEvent;
public class KafkaClientBoundConsumer extends KafkaConsumer<ClientBoundEvent> {
private static final KafkaChannelCodec CODEC = KafkaChannelCodec.CLIENT_BOUND_EVENT;
private final String lane;
private final String name;
@ -11,15 +12,15 @@ public class KafkaClientBoundConsumer extends KafkaConsumer<ClientBoundEvent> {
super(kafkaParameters);
this.lane = lane;
if (lane.isBlank()) {
this.name = KafkaChannelCodec.CLIENT_BOUND_EVENT.getKafkaName();
this.name = CODEC.getKafkaName();
} else {
this.name = KafkaChannelCodec.CLIENT_BOUND_EVENT.getKafkaName() + "-" + lane;
this.name = CODEC.getKafkaName() + "-" + lane;
}
}
@Override
public KafkaChannelCodec getChannelCodec() {
return KafkaChannelCodec.CLIENT_BOUND_EVENT;
return CODEC;
}
@Override

View File

@ -4,20 +4,22 @@ import it.tdlight.reactiveapi.Event.ClientBoundEvent;
public class KafkaClientBoundProducer extends KafkaProducer<ClientBoundEvent> {
private static final KafkaChannelCodec CODEC = KafkaChannelCodec.CLIENT_BOUND_EVENT;
private final String name;
public KafkaClientBoundProducer(KafkaParameters kafkaParameters, String lane) {
super(kafkaParameters);
if (lane.isBlank()) {
this.name = KafkaChannelCodec.CLIENT_BOUND_EVENT.getKafkaName();
this.name = CODEC.getKafkaName();
} else {
this.name = KafkaChannelCodec.CLIENT_BOUND_EVENT.getKafkaName() + "-" + lane;
this.name = CODEC.getKafkaName() + "-" + lane;
}
}
@Override
public KafkaChannelCodec getChannelCodec() {
return KafkaChannelCodec.CLIENT_BOUND_EVENT;
return CODEC;
}
@Override

View File

@ -44,7 +44,7 @@ public abstract class KafkaProducer<K> {
var channelName = getChannelName();
return eventsFlux
.<SenderRecord<Integer, K, Integer>>map(event ->
SenderRecord.create(new ProducerRecord<>(channelName, event), null))
SenderRecord.create(new ProducerRecord<>("tdlib." + channelName, event), null))
.log("produce-messages-" + channelName,
Level.FINEST,
SignalType.REQUEST,