add some initial standalone raft node code

This commit is contained in:
Raycho Mukelov 2023-09-08 20:03:05 +03:00
parent a31afea620
commit 5c10cf6ac4
2 changed files with 21 additions and 0 deletions

BIN
Dockerfile.zip Normal file

Binary file not shown.

View File

@ -1,6 +1,27 @@
import ../raft
import basic_state_machine
import std/json
import uuids
import chronicles
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:
var node = RaftNode[SmCommand, SmState].new()