MCPcopy
hub / github.com/dgraph-io/dgraph / Leader

Method Leader

dgraph/cmd/zero/zero.go:173–199  ·  view source on GitHub ↗

Leader returns a connection pool to the zero leader.

(gid uint32)

Source from the content-addressed store, hash-verified

171
172// Leader returns a connection pool to the zero leader.
173func (s *Server) Leader(gid uint32) *conn.Pool {
174 s.RLock()
175 defer s.RUnlock()
176 if s.state == nil {
177 return nil
178 }
179 var members map[uint64]*pb.Member
180 if gid == 0 {
181 members = s.state.Zeros
182 } else {
183 group := s.state.Groups[gid]
184 if group == nil {
185 return nil
186 }
187 members = group.Members
188 }
189 var healthyPool *conn.Pool
190 for _, m := range members {
191 if pl, err := conn.GetPools().Get(m.Addr); err == nil {
192 healthyPool = pl
193 if m.Leader {
194 return pl
195 }
196 }
197 }
198 return healthyPool
199}
200
201// KnownGroups returns a list of the known groups.
202func (s *Server) KnownGroups() []uint32 {

Callers 3

deletePredicatesMethod · 0.95
AssignIdsMethod · 0.95
movePredicateMethod · 0.95

Calls 4

GetPoolsFunction · 0.92
RLockMethod · 0.80
RUnlockMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected