
pl.allegro.tech.hermes.management.domain.detection.InactiveTopic Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hermes-management Show documentation
Show all versions of hermes-management Show documentation
Fast and reliable message broker built on top of Kafka.
package pl.allegro.tech.hermes.management.domain.detection;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
public record InactiveTopic(
@JsonProperty("topic") String qualifiedTopicName,
@JsonProperty("lastPublishedTsMs") long lastPublishedMessageTimestampMs,
@JsonProperty("notificationTsMs") List notificationTimestampsMs,
@JsonProperty("whitelisted") boolean whitelisted) {
InactiveTopic notificationSent(Instant timestamp) {
List newNotificationTimestampsMs = new ArrayList<>(notificationTimestampsMs);
newNotificationTimestampsMs.add(timestamp.toEpochMilli());
return new InactiveTopic(
this.qualifiedTopicName,
this.lastPublishedMessageTimestampMs,
newNotificationTimestampsMs,
this.whitelisted);
}
InactiveTopic limitNotificationsHistory(int limit) {
List newNotificationTimestampsMs =
notificationTimestampsMs.stream()
.sorted((a, b) -> Long.compare(b, a))
.limit(limit)
.toList();
return new InactiveTopic(
this.qualifiedTopicName,
this.lastPublishedMessageTimestampMs,
newNotificationTimestampsMs,
this.whitelisted);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy