All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cultureamp.eventsourcing.AsyncEventProcessorMonitor.kt Maven / Gradle / Ivy

The newest version!
package com.cultureamp.eventsourcing

class AsyncEventProcessorMonitor(
    private val asyncEventProcessors: List>,
    private val metrics: (Lag) -> Unit,
) {
    fun run() {
        val lags = asyncEventProcessors.map {
            val bookmarkSequence = it.bookmarkStore.bookmarkFor(it.bookmarkName).sequence
            val lastSequence = it.eventsSequenceStats.lastSequence(it.sequencedEventProcessor.domainEventClasses())
            Lag(
                name = it.bookmarkName,
                bookmarkSequence = bookmarkSequence,
                lastSequence = lastSequence,
            )
        }

        lags.forEach {
            metrics(it)
        }
    }
}

data class Lag(val name: String, val bookmarkSequence: Long, val lastSequence: Long) {
    val lag: Long = lastSequence - bookmarkSequence
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy