mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-03 22:43:09 +00:00
Split `WakuNodeConfig` object for better separation of concerns and to introduce a tree-like structure to configuration. * fix: ensure twn cluster conf is still applied when clusterId=1 * test: remove usage of `WakuNodeConf` * Remove macro, split builder files, remove wakunodeconf from tests * rm network_conf_builder module as it is not used --------- Co-authored-by: NagyZoltanPeter <113987313+NagyZoltanPeter@users.noreply.github.com> Co-authored-by: Ivan Folgueira Bande <ivansete@status.im>
41 lines
1.3 KiB
Nim
41 lines
1.3 KiB
Nim
{.push raises: [].}
|
|
|
|
import metrics
|
|
|
|
proc parseCollectorIntoF64(collector: SimpleCollector): float64 {.gcsafe, raises: [].} =
|
|
{.gcsafe.}:
|
|
var total = 0.float64
|
|
for metrics in collector.metrics:
|
|
for metric in metrics:
|
|
try:
|
|
total = total + metric.value
|
|
except KeyError:
|
|
discard
|
|
return total
|
|
|
|
template parseAndAccumulate*(collector: Collector, cumulativeValue: float64): float64 =
|
|
## This template is used to get metrics in a window
|
|
## according to a cumulative value passed in
|
|
{.gcsafe.}:
|
|
let total = parseCollectorIntoF64(collector)
|
|
let freshCount = total - cumulativeValue
|
|
cumulativeValue = total
|
|
freshCount
|
|
|
|
template parseAndAccumulate*(
|
|
collector: typedesc[IgnoredCollector], cumulativeValue: float64
|
|
): float64 =
|
|
## Used when metrics are disabled (undefined `metrics` compilation flag)
|
|
0.0
|
|
|
|
template collectorAsF64*(collector: Collector): float64 =
|
|
## This template is used to get metrics from 0
|
|
## Serves as a wrapper for parseCollectorIntoF64 which is gcsafe
|
|
{.gcsafe.}:
|
|
let total = parseCollectorIntoF64(collector)
|
|
total
|
|
|
|
template collectorAsF64*(collector: typedesc[IgnoredCollector]): float64 =
|
|
## Used when metrics are disabled (undefined `metrics` compilation flag)
|
|
0.0
|