MCPcopy Create free account
hub / github.com/apache/kvrocks-controller / New

Function New

store/engine/raft/node.go:90–110  ·  view source on GitHub ↗
(config *Config)

Source from the content-addressed store, hash-verified

88var _ engine.Engine = (*Node)(nil)
89
90func New(config *Config) (*Node, error) {
91 config.init()
92 if err := config.validate(); err != nil {
93 return nil, err
94 }
95
96 logger := logger.Get().With(zap.Uint64("node_id", config.ID))
97 n := &Node{
98 config: config,
99 leader: raft.None,
100 dataStore: NewDataStore(config.DataDir),
101 leaderChanged: make(chan bool),
102 logger: logger,
103 }
104 n.snapshotThreshold.Store(defaultSnapshotThreshold)
105 n.compactThreshold.Store(defaultCompactThreshold)
106 if err := n.run(); err != nil {
107 return nil, err
108 }
109 return n, nil
110}
111
112func (n *Node) Addr() string {
113 return n.addr

Callers 3

NewServerFunction · 0.92
NewTestClusterFunction · 0.70
createNodeMethod · 0.70

Calls 5

runMethod · 0.95
GetFunction · 0.92
NewDataStoreFunction · 0.85
initMethod · 0.80
validateMethod · 0.45

Tested by 2

NewTestClusterFunction · 0.56
createNodeMethod · 0.56