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

Function proposeOrSend

worker/mutation.go:651–686  ·  view source on GitHub ↗

proposeOrSend either proposes the mutation if the node serves the group gid or sends it to the leader of the group gid for proposing.

(ctx context.Context, gid uint32, m *pb.Mutations, chr chan res)

Source from the content-addressed store, hash-verified

649// proposeOrSend either proposes the mutation if the node serves the group gid or sends it to
650// the leader of the group gid for proposing.
651func proposeOrSend(ctx context.Context, gid uint32, m *pb.Mutations, chr chan res) {
652 res := res{}
653 if groups().ServesGroup(gid) {
654 res.ctx = &api.TxnContext{}
655 res.err = (&grpcWorker{}).proposeAndWait(ctx, res.ctx, m)
656 chr <- res
657 return
658 }
659
660 pl := groups().Leader(gid)
661 if pl == nil {
662 res.err = conn.ErrNoConnection
663 chr <- res
664 return
665 }
666
667 var tc *api.TxnContext
668 c := pb.NewWorkerClient(pl.Get())
669
670 ch := make(chan error, 1)
671 go func() {
672 var err error
673 tc, err = c.Mutate(ctx, m)
674 ch <- err
675 }()
676
677 select {
678 case <-ctx.Done():
679 res.err = ctx.Err()
680 res.ctx = nil
681 case err := <-ch:
682 res.err = err
683 res.ctx = tc
684 }
685 chr <- res
686}
687
688// populateMutationMap populates a map from group id to the mutation that
689// should be sent to that group.

Callers 1

MutateOverNetworkFunction · 0.85

Calls 8

MutateMethod · 0.95
NewWorkerClientFunction · 0.92
groupsFunction · 0.85
ServesGroupMethod · 0.80
GetMethod · 0.65
proposeAndWaitMethod · 0.45
LeaderMethod · 0.45
DoneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…