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

Function resolveTask

graphql/admin/task.go:27–58  ·  view source on GitHub ↗
(ctx context.Context, q schema.Query)

Source from the content-addressed store, hash-verified

25}
26
27func resolveTask(ctx context.Context, q schema.Query) *resolve.Resolved {
28 // Get Task ID.
29 input, err := getTaskInput(q)
30 if err != nil {
31 return resolve.EmptyResult(q, err)
32 }
33 if input.Id == "" {
34 return resolve.EmptyResult(q, fmt.Errorf("task ID is missing"))
35 }
36 taskId, err := strconv.ParseUint(input.Id, 0, 64)
37 if err != nil {
38 err = errors.Wrapf(err, "invalid task ID: %s", input.Id)
39 return resolve.EmptyResult(q, err)
40 }
41
42 // Get TaskMeta from network.
43 req := &pb.TaskStatusRequest{TaskId: taskId}
44 resp, err := worker.TaskStatusOverNetwork(context.Background(), req)
45 if err != nil {
46 return resolve.EmptyResult(q, err)
47 }
48 meta := worker.TaskMeta(resp.GetTaskMeta())
49 return resolve.DataResult(
50 q,
51 map[string]interface{}{q.Name(): map[string]interface{}{
52 "kind": meta.Kind().String(),
53 "status": meta.Status().String(),
54 "lastUpdated": meta.Timestamp().Format(time.RFC3339),
55 }},
56 nil,
57 )
58}
59
60func getTaskInput(q schema.Query) (*taskInput, error) {
61 inputArg := q.ArgValue(schema.InputArgName)

Callers

nothing calls this directly

Calls 13

EmptyResultFunction · 0.92
TaskStatusOverNetworkFunction · 0.92
TaskMetaTypeAlias · 0.92
DataResultFunction · 0.92
getTaskInputFunction · 0.85
GetTaskMetaMethod · 0.80
KindMethod · 0.80
StatusMethod · 0.80
FormatMethod · 0.80
TimestampMethod · 0.80
NameMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected