-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
José Carlos Montañez
authored and
José Carlos Montañez
committed
Sep 4, 2024
1 parent
accfc6e
commit e908824
Showing
2 changed files
with
6 additions
and
3 deletions.
There are no files selected for viewing
5 changes: 4 additions & 1 deletion
5
core/src/commonMain/kotlin/com/xebia/functional/xef/metrics/InMemoryCounterMetric.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
package com.xebia.functional.xef.metrics | ||
|
||
import arrow.atomic.AtomicLong | ||
import io.github.oshai.kotlinlogging.KLogger | ||
|
||
class InMemoryCounterMetric : CounterMetric { | ||
class InMemoryCounterMetric(val name: String, val logger: KLogger) : CounterMetric { | ||
private val count = AtomicLong(0) | ||
|
||
override fun increment(n: Long) { | ||
count.incrementAndGet() | ||
logger.info { "Counter $name incremented to ${count.get()}" } | ||
} | ||
|
||
override fun decrement(n: Long) { | ||
count.decrementAndGet() | ||
logger.info { "Counter $name decremented to ${count.get()}" } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters