mirror of
https://github.com/status-im/nim-raft.git
synced 2025-01-29 06:14:53 +00:00
29 lines
647 B
Nim
29 lines
647 B
Nim
import ../raft
|
|
import basic_state_machine
|
|
import std/json
|
|
import uuids
|
|
import chronicles
|
|
import msgpack4nim
|
|
|
|
type
|
|
RaftPeerConf = object
|
|
id: UUID
|
|
host: string
|
|
port: int
|
|
|
|
RaftPeersConfContainer = seq[RaftPeerConf]
|
|
|
|
var
|
|
conf: RaftPeersConfContainer
|
|
|
|
proc loadConfig() =
|
|
let jsonFile = "raft_node_config.json"
|
|
# read and parse file
|
|
let jsConf = parseFile(jsonFile)
|
|
for n in jsConf["raftPeers"]:
|
|
conf.add(RaftPeerConf(id: parseUUID(n["id"].astToStr), host: n["host"].astToStr, port: int(n["port"].astToStr)))
|
|
info "Conf", config=repr(conf)
|
|
|
|
if isMainModule:
|
|
loadConfig()
|
|
var node = RaftNode[SmCommand, SmState].new() |