If peers is nil, the peerPicker is called via a sync.Once to initialize it.
(name string, cacheBytes int64, getter Getter, peers PeerPicker)
| 87 | |
| 88 | // If peers is nil, the peerPicker is called via a sync.Once to initialize it. |
| 89 | func 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. |
| 114 | var newGroupHook func(*Group) |
searching dependent graphs…