add some initial standalone raft node code
This commit is contained in:
parent
a31afea620
commit
5c10cf6ac4
Binary file not shown.
|
@ -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()
|
Loading…
Reference in New Issue