MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / handleCommit

Function handleCommit

dgraph/cmd/alpha/http.go:581–625  ·  view source on GitHub ↗
(ctx context.Context,
	startTs uint64, hash string, reqText []byte)

Source from the content-addressed store, hash-verified

579}
580
581func handleCommit(ctx context.Context,
582 startTs uint64, hash string, reqText []byte) (map[string]interface{}, error) {
583 tc := &api.TxnContext{
584 StartTs: startTs,
585 Hash: hash,
586 }
587
588 var reqList []string
589 useList := false
590 if err := json.Unmarshal(reqText, &reqList); err == nil {
591 useList = true
592 }
593
594 var reqMap map[string][]string
595 if err := json.Unmarshal(reqText, &reqMap); err != nil && !useList {
596 return nil, err
597 }
598
599 if useList {
600 tc.Keys = reqList
601 } else {
602 tc.Keys = reqMap["keys"]
603 tc.Preds = reqMap["preds"]
604 }
605
606 tc, err := (&edgraph.Server{}).CommitOrAbort(ctx, tc)
607 if err != nil {
608 return nil, err
609 }
610
611 resp := &api.Response{}
612 resp.Txn = tc
613 e := query.Extensions{
614 Txn: resp.Txn,
615 }
616 e.Txn.Keys = e.Txn.Keys[:0]
617 response := map[string]interface{}{}
618 response["extensions"] = e
619 mp := map[string]interface{}{}
620 mp["code"] = x.Success
621 mp["message"] = "Done"
622 response["data"] = mp
623
624 return response, nil
625}
626
627func alterHandler(w http.ResponseWriter, r *http.Request) {
628 if commonHandler(w, r) {

Callers 1

commitHandlerFunction · 0.85

Calls 1

CommitOrAbortMethod · 0.65

Tested by

no test coverage detected