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

Function WaitForIndexing

worker/graphql_schema.go:251–262  ·  view source on GitHub ↗

WaitForIndexing does a busy wait for indexing to finish or the context to error out, if the input flag shouldWait is true. Otherwise, it just returns nil straight away. If the context errors, it returns that error. TODO(aman): we should return an error if the indexing fails

(ctx context.Context, shouldWait bool)

Source from the content-addressed store, hash-verified

249// If the context errors, it returns that error.
250// TODO(aman): we should return an error if the indexing fails
251func WaitForIndexing(ctx context.Context, shouldWait bool) error {
252 for shouldWait {
253 if ctx.Err() != nil {
254 return ctx.Err()
255 }
256 if !schema.State().IndexingInProgress() {
257 break
258 }
259 time.Sleep(time.Second * 2)
260 }
261 return nil
262}
263
264// isGroupOneLeader returns true if the current server is the leader of Group One,
265// it returns false otherwise.

Callers 2

alterMethod · 0.92
UpdateGraphQLSchemaMethod · 0.85

Calls 2

StateFunction · 0.92
IndexingInProgressMethod · 0.80

Tested by

no test coverage detected