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

Function getWriteTimestamp

dgraph/cmd/bulk/loader.go:223–248  ·  view source on GitHub ↗
(zero *grpc.ClientConn, dg *dgo.Dgraph)

Source from the content-addressed store, hash-verified

221}
222
223func getWriteTimestamp(zero *grpc.ClientConn, dg *dgo.Dgraph) uint64 {
224 if zero != nil {
225 client := pb.NewZeroClient(zero)
226 for {
227 ctx, cancel := context.WithTimeout(context.Background(), time.Second)
228 ts, err := client.Timestamps(ctx, &pb.Num{Val: 1})
229 cancel()
230 if err == nil {
231 return ts.GetStartId()
232 }
233 fmt.Printf("Error communicating with dgraph zero, retrying: %v", err)
234 time.Sleep(time.Second)
235 }
236 }
237
238 for {
239 ctx, cancel := context.WithTimeout(context.Background(), time.Second)
240 _, ts, err := dg.AllocateTimestamps(ctx, 1)
241 cancel()
242 if err == nil {
243 return ts
244 }
245 fmt.Printf("Error communicating with dgraph alpha, retrying: %v", err)
246 time.Sleep(time.Second)
247 }
248}
249
250// leaseNamespace is called at the end of map phase. It leases the namespace ids till the maximum
251// seen namespace id.

Callers 1

newLoaderFunction · 0.85

Calls 3

TimestampsMethod · 0.95
NewZeroClientFunction · 0.92
GetStartIdMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…