MCPcopy Index your code
hub / github.com/coder/coder / graph

Method graph

provisionerd/runner/graph.go:13–64  ·  view source on GitHub ↗
(ctx context.Context, req *sdkproto.GraphRequest)

Source from the content-addressed store, hash-verified

11)
12
13func (r *Runner) graph(ctx context.Context, req *sdkproto.GraphRequest) (*sdkproto.GraphComplete, *proto.FailedJob) {
14 ctx, span := r.startTrace(ctx, tracing.FuncName())
15 defer span.End()
16
17 err := r.session.Send(&sdkproto.Request{Type: &sdkproto.Request_Graph{Graph: req}})
18 if err != nil {
19 return nil, r.failedJobf("send graph request: %v", err)
20 }
21
22 nevermind := make(chan struct{})
23 defer close(nevermind)
24 go func() {
25 select {
26 case <-nevermind:
27 return
28 case <-r.notStopped.Done():
29 return
30 case <-r.notCanceled.Done():
31 _ = r.session.Send(&sdkproto.Request{
32 Type: &sdkproto.Request_Cancel{
33 Cancel: &sdkproto.CancelRequest{},
34 },
35 })
36 }
37 }()
38
39 for {
40 msg, err := r.session.Recv()
41 if err != nil {
42 return nil, r.failedJobf("receive graph response: %v", err)
43 }
44 switch msgType := msg.Type.(type) {
45 case *sdkproto.Response_Log:
46 r.logProvisionerJobLog(context.Background(), msgType.Log.Level, "terraform graphing",
47 slog.F("level", msgType.Log.Level),
48 slog.F("output", msgType.Log.Output),
49 )
50
51 r.queueLog(ctx, &proto.Log{
52 Source: proto.LogSource_PROVISIONER,
53 Level: msgType.Log.Level,
54 CreatedAt: time.Now().UnixMilli(),
55 Output: msgType.Log.Output,
56 Stage: "Graphing Infrastructure",
57 })
58 case *sdkproto.Response_Graph:
59 return msgType.Graph, nil
60 default:
61 return nil, r.failedJobf("unexpected graph response type %T", msg.Type)
62 }
63 }
64}

Callers 3

runWorkspaceBuildMethod · 0.95
GraphMethod · 0.45

Calls 8

startTraceMethod · 0.95
failedJobfMethod · 0.95
logProvisionerJobLogMethod · 0.95
queueLogMethod · 0.95
FuncNameFunction · 0.92
SendMethod · 0.65
RecvMethod · 0.65
DoneMethod · 0.45

Tested by 1

GraphMethod · 0.36