MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / Set

Method Set

consistent/consistent.go:167–184  ·  view source on GitHub ↗

Set sets all the nodes in the hash. If there are existing nodes not present in nodes, they will be removed.

(nodes []proto.Node)

Source from the content-addressed store, hash-verified

165// Set sets all the nodes in the hash. If there are existing nodes not
166// present in nodes, they will be removed.
167func (c *Consistent) Set(nodes []proto.Node) (err error) {
168 c.Lock()
169 defer c.Unlock()
170
171 err = c.persist.Reset()
172 if err != nil {
173 log.WithError(err).Error("reset bucket failed")
174 return
175 }
176
177 c.ResetCache()
178
179 for _, v := range nodes {
180 c.add(v)
181 }
182
183 return
184}
185
186// need c.Lock() before calling.
187func (c *Consistent) add(node proto.Node) (err error) {

Callers 2

TestSetFunction · 0.45
TestConcurrentGetSetFunction · 0.45

Calls 5

ResetCacheMethod · 0.95
addMethod · 0.95
WithErrorFunction · 0.92
ErrorMethod · 0.80
ResetMethod · 0.65

Tested by 2

TestSetFunction · 0.36
TestConcurrentGetSetFunction · 0.36