MCPcopy Index your code
hub / github.com/golang/groupcache / newGroup

Function newGroup

groupcache.go:89–111  ·  view source on GitHub ↗

If peers is nil, the peerPicker is called via a sync.Once to initialize it.

(name string, cacheBytes int64, getter Getter, peers PeerPicker)

Source from the content-addressed store, hash-verified

87
88// If peers is nil, the peerPicker is called via a sync.Once to initialize it.
89func newGroup(name string, cacheBytes int64, getter Getter, peers PeerPicker) *Group {
90 if getter == nil {
91 panic("nil Getter")
92 }
93 mu.Lock()
94 defer mu.Unlock()
95 initPeerServerOnce.Do(callInitPeerServer)
96 if _, dup := groups[name]; dup {
97 panic("duplicate registration of group " + name)
98 }
99 g := &Group{
100 name: name,
101 getter: getter,
102 peers: peers,
103 cacheBytes: cacheBytes,
104 loadGroup: &singleflight.Group{},
105 }
106 if fn := newGroupHook; fn != nil {
107 fn(g)
108 }
109 groups[name] = g
110 return g
111}
112
113// newGroupHook, if non-nil, is called right after a new group is created.
114var newGroupHook func(*Group)

Callers 3

TestPeersFunction · 0.85
TestNoDedupFunction · 0.85
NewGroupFunction · 0.85

Calls 1

DoMethod · 0.65

Tested by 2

TestPeersFunction · 0.68
TestNoDedupFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…