ApplyMutations performs the required edge expansions and forwards the results to the worker to perform the mutations.
(ctx context.Context, m *pb.Mutations)
| 26 | // ApplyMutations performs the required edge expansions and forwards the results to the |
| 27 | // worker to perform the mutations. |
| 28 | func ApplyMutations(ctx context.Context, m *pb.Mutations) (*api.TxnContext, error) { |
| 29 | // In expandEdges, for non * type prredicates, we prepend the namespace directly and for |
| 30 | // * type predicates, we fetch the predicates and prepend the namespace. |
| 31 | edges, err := ExpandEdges(ctx, m) |
| 32 | if err != nil { |
| 33 | return nil, errors.Wrapf(err, "While adding pb.edges") |
| 34 | } |
| 35 | m.Edges = edges |
| 36 | |
| 37 | err = checkIfDeletingAclOperation(ctx, m.Edges) |
| 38 | if err != nil { |
| 39 | return nil, err |
| 40 | } |
| 41 | tctx, err := worker.MutateOverNetwork(ctx, m) |
| 42 | if err != nil { |
| 43 | span := trace.SpanFromContext(ctx) |
| 44 | span.AddEvent("MutateOverNetwork Error", trace.WithAttributes( |
| 45 | attribute.String("error", err.Error()), |
| 46 | attribute.String("mutation", m.String()))) |
| 47 | } |
| 48 | return tctx, err |
| 49 | } |
| 50 | |
| 51 | func ExpandEdges(ctx context.Context, m *pb.Mutations) ([]*pb.DirectedEdge, error) { |
| 52 | edges := make([]*pb.DirectedEdge, 0, 2*len(m.Edges)) |
no test coverage detected