-
Notifications
You must be signed in to change notification settings - Fork 5
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
1 parent
e4cc607
commit 6236f36
Showing
27 changed files
with
183 additions
and
37 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
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
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
22 changes: 22 additions & 0 deletions
22
btc-withdrawal/src/main/kotlin/withdrawal/btc/statistics/WithdrawalStatistics.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package withdrawal.btc.statistics | ||
|
||
import java.util.concurrent.atomic.AtomicInteger | ||
|
||
/** | ||
* Data class that holds short statistics about withdrawal service | ||
*/ | ||
data class WithdrawalStatistics( | ||
val totalTransfers: AtomicInteger, | ||
val failedTransfers: AtomicInteger, | ||
val succeededTransfers: AtomicInteger | ||
) { | ||
fun incTotalTransfers() = totalTransfers.incrementAndGet() | ||
|
||
fun incFailedTransfers() = failedTransfers.incrementAndGet() | ||
|
||
fun incSucceededTransfers() = succeededTransfers.incrementAndGet() | ||
|
||
companion object { | ||
fun create() = WithdrawalStatistics(AtomicInteger(), AtomicInteger(), AtomicInteger()) | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package monitoring | ||
|
||
import com.github.kittinunf.result.Result | ||
import org.springframework.jmx.export.annotation.ManagedAttribute | ||
import org.springframework.jmx.export.annotation.ManagedResource | ||
import util.toJson | ||
|
||
/* | ||
* Class that was developed to help you monitor things | ||
*/ | ||
@ManagedResource | ||
abstract class Monitoring { | ||
|
||
/* | ||
* Returns an object that must monitored | ||
*/ | ||
protected abstract fun monitor(): Any | ||
|
||
/* | ||
* Takes monitored object and turns it into JSON. | ||
* This function is used by JMX | ||
*/ | ||
@ManagedAttribute | ||
fun getMonitoring(): String { | ||
val objectToMonitor = monitor() | ||
if (objectToMonitor !is Result<Any, Exception>) { | ||
return String.toJson(objectToMonitor) | ||
} | ||
return objectToMonitor.fold( | ||
{ data -> String.toJson(data) }, | ||
{ ex -> throw ex }) | ||
} | ||
} |
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
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
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
Oops, something went wrong.