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

Function getSchemaOverNetwork

worker/schema.go:163–178  ·  view source on GitHub ↗

If the current node serves the group serve the schema or forward to relevant node TODO: Janardhan - if read fails try other servers serving same group

(ctx context.Context, gid uint32, s *pb.SchemaRequest, ch chan resultErr)

Source from the content-addressed store, hash-verified

161// to relevant node
162// TODO: Janardhan - if read fails try other servers serving same group
163func getSchemaOverNetwork(ctx context.Context, gid uint32, s *pb.SchemaRequest, ch chan resultErr) {
164 if groups().ServesGroup(gid) {
165 schema, e := getSchema(ctx, s)
166 ch <- resultErr{result: schema, err: e}
167 return
168 }
169
170 pl := groups().Leader(gid)
171 if pl == nil {
172 ch <- resultErr{err: conn.ErrNoConnection}
173 return
174 }
175 c := pb.NewWorkerClient(pl.Get())
176 schema, e := c.Schema(ctx, s)
177 ch <- resultErr{result: schema, err: e}
178}
179
180// GetSchemaOverNetwork checks which group should be serving the schema
181// according to fingerprint of the predicate and sends it to that instance.

Callers 1

GetSchemaOverNetworkFunction · 0.85

Calls 7

SchemaMethod · 0.95
NewWorkerClientFunction · 0.92
groupsFunction · 0.85
ServesGroupMethod · 0.80
getSchemaFunction · 0.70
GetMethod · 0.65
LeaderMethod · 0.45

Tested by

no test coverage detected