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

Method Timestamps

dgraph/cmd/zero/oracle.go:495–520  ·  view source on GitHub ↗

Timestamps is used to assign startTs for a new transaction

(ctx context.Context, num *pb.Num)

Source from the content-addressed store, hash-verified

493
494// Timestamps is used to assign startTs for a new transaction
495func (s *Server) Timestamps(ctx context.Context, num *pb.Num) (*pb.AssignedIds, error) {
496 ctx, span := otel.Tracer("").Start(ctx, "Zero.Timestamps")
497 defer span.End()
498
499 span.SetAttributes(attribute.Int64("zeroId", int64(s.Node.Id)))
500 span.SetAttributes(attribute.String("timestampRequest", fmt.Sprintf("%+v", num)))
501 if ctx.Err() != nil {
502 return &emptyAssignedIds, ctx.Err()
503 }
504
505 num.Type = pb.Num_TXN_TS
506 reply, err := s.lease(ctx, num)
507 span.AddEvent(fmt.Sprintf("Response: %+v, Error: %v", reply, err))
508
509 switch err {
510 case nil:
511 s.orc.doneUntil.Done(x.Max(reply.EndId, reply.ReadOnly))
512 go s.orc.storePending(reply)
513 case errServedFromMemory:
514 // Avoid calling doneUntil.Done, and storePending.
515 err = nil
516 default:
517 glog.Errorf("Got error: %v while leasing timestamps: %+v", err, num)
518 }
519 return reply, err
520}

Callers 1

movePredicateMethod · 0.95

Calls 7

leaseMethod · 0.95
MaxFunction · 0.92
storePendingMethod · 0.80
StartMethod · 0.65
StringMethod · 0.45
DoneMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected