mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-08 17:03: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>
48 lines
1.4 KiB
Nim
48 lines
1.4 KiB
Nim
import chronicles, std/[net, options], results
|
|
import ../waku_conf
|
|
|
|
logScope:
|
|
topics = "waku conf builder metrics server"
|
|
|
|
###################################
|
|
## 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(false):
|
|
return ok(none(MetricsServerConf))
|
|
|
|
return ok(
|
|
some(
|
|
MetricsServerConf(
|
|
httpAddress: b.httpAddress.get(static parseIpAddress("127.0.0.1")),
|
|
httpPort: b.httpPort.get(8008.Port),
|
|
logging: b.logging.get(false),
|
|
)
|
|
)
|
|
)
|