MCPcopy Create free account
hub / github.com/PacktPublishing/System-Programming-Essentials-with-Go / NewCacheServer

Function NewCacheServer

ch13/server.go:27–38  ·  view source on GitHub ↗
(peers []string)

Source from the content-addressed store, hash-verified

25}
26
27func NewCacheServer(peers []string) *CacheServer {
28 cs := &CacheServer{
29 cache: NewCache(10),
30 peers: peers,
31 hashRing: NewHashRing(),
32 }
33 for _, peer := range peers {
34 cs.hashRing.AddNode(Node{ID: peer, Addr: peer})
35 }
36
37 return cs
38}
39
40func (cs *CacheServer) SetHandler(w http.ResponseWriter, r *http.Request) {
41 var req struct {

Callers

nothing calls this directly

Calls 3

NewCacheFunction · 0.85
NewHashRingFunction · 0.85
AddNodeMethod · 0.80

Tested by

no test coverage detected