goodmetrics.pipeline.BatchSender.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of goodmetrics-kotlin Show documentation
Show all versions of goodmetrics-kotlin Show documentation
A metrics recording library that is good
package goodmetrics.pipeline
import goodmetrics.downstream.GoodmetricsClient
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
class BatchSender private constructor() {
companion object {
fun CoroutineScope.launchSender(upstream: MetricsPipeline, client: GoodmetricsClient, send: suspend GoodmetricsClient.(batch: TBatch) -> Unit): Job {
return launch {
upstream.consume()
.collect { batch ->
client.send(batch)
}
}
}
}
}