MCPcopy Create free account
hub / github.com/dgraph-io/dgraph / PollTillPassOrTimeout

Function PollTillPassOrTimeout

dgraphapi/json.go:27–47  ·  view source on GitHub ↗
(gcli *GrpcClient, query, want string, timeout time.Duration)

Source from the content-addressed store, hash-verified

25)
26
27func PollTillPassOrTimeout(gcli *GrpcClient, query, want string, timeout time.Duration) error {
28 timer := time.NewTimer(timeout)
29
30 for {
31 resp, err := gcli.Query(query)
32 if err != nil {
33 return errors.Wrap(err, "error while query")
34 }
35
36 err = CompareJSON(want, string(resp.Json))
37 if err == nil {
38 return nil
39 }
40 select {
41 case <-timer.C:
42 return err
43 default:
44 time.Sleep(waitDurBeforeRetry)
45 }
46 }
47}
48
49// CompareJSON compares two JSON objects (passed as strings).
50func CompareJSON(want, got string) error {

Calls 2

CompareJSONFunction · 0.70
QueryMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…