mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-05-14 14:29:29 +00:00
* Soft-deprecate --cluster-id=N triggering the associated preset selection * Rewrite applyNetworkConf to apply user-set fields over preset fields * Add createNode(preset, mode, overrides, additions) nim api * Generate WakuNodeConfOverlay (all Option fields) from WakuNodeConf * New parser for configJson handles new messaging shape and full conf shape * Change all confbuilder defaults from literal values to DefaultXXX consts * Change int/bool WakuNodeConf fields to Option to get user intent w/o sentinels * Make Option CLI default-value help mention defaults now owned by confbuilder * Misc refactors, fixes * Add tests
54 lines
1.6 KiB
Nim
54 lines
1.6 KiB
Nim
import chronicles, std/[net, options], results
|
|
import ../waku_conf
|
|
|
|
logScope:
|
|
topics = "waku conf builder metrics server"
|
|
|
|
const
|
|
DefaultMetricsEnabled*: bool = false
|
|
DefaultMetricsHttpAddress*: IpAddress = static parseIpAddress("127.0.0.1")
|
|
DefaultMetricsHttpPort*: Port = Port(0)
|
|
DefaultMetricsLogging*: bool = false
|
|
|
|
###################################
|
|
## Metrics Server Config Builder ##
|
|
###################################
|
|
type MetricsServerConfBuilder* = object
|
|
enabled*: Option[bool]
|
|
|
|
httpAddress*: Option[IpAddress]
|
|
httpPort*: Option[Port]
|
|
logging*: Option[bool]
|
|
|
|
proc init*(T: type MetricsServerConfBuilder): MetricsServerConfBuilder =
|
|
MetricsServerConfBuilder()
|
|
|
|
proc withEnabled*(b: var MetricsServerConfBuilder, enabled: bool) =
|
|
b.enabled = some(enabled)
|
|
|
|
proc withHttpAddress*(b: var MetricsServerConfBuilder, httpAddress: IpAddress) =
|
|
b.httpAddress = some(httpAddress)
|
|
|
|
proc withHttpPort*(b: var MetricsServerConfBuilder, httpPort: Port) =
|
|
b.httpPort = some(httpPort)
|
|
|
|
proc withHttpPort*(b: var MetricsServerConfBuilder, httpPort: uint16) =
|
|
b.httpPort = some(Port(httpPort))
|
|
|
|
proc withLogging*(b: var MetricsServerConfBuilder, logging: bool) =
|
|
b.logging = some(logging)
|
|
|
|
proc build*(b: MetricsServerConfBuilder): Result[Option[MetricsServerConf], string] =
|
|
if not b.enabled.get(DefaultMetricsEnabled):
|
|
return ok(none(MetricsServerConf))
|
|
|
|
return ok(
|
|
some(
|
|
MetricsServerConf(
|
|
httpAddress: b.httpAddress.get(DefaultMetricsHttpAddress),
|
|
httpPort: b.httpPort.get(DefaultMetricsHttpPort),
|
|
logging: b.logging.get(DefaultMetricsLogging),
|
|
)
|
|
)
|
|
)
|