MCPcopy Index your code
hub / github.com/dagger/dagger / dispatch

Function dispatch

toolchains/engine-dev/dagger.gen.go:182–247  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

180 }
181}
182func dispatch(ctx context.Context) (rerr error) {
183 ctx = telemetry.InitEmbedded(ctx, resource.NewWithAttributes(
184 semconv.SchemaURL,
185 semconv.ServiceNameKey.String("dagger-go-sdk"),
186 // TODO version?
187 ))
188 defer telemetry.Close()
189
190 // A lot of the "work" actually happens when we're marshalling the return
191 // value, which entails getting object IDs, which happens in MarshalJSON,
192 // which has no ctx argument, so we use this lovely global variable.
193 setMarshalContext(ctx)
194
195 fnCall := dag.CurrentFunctionCall()
196 defer func() {
197 if rerr != nil {
198 if err := fnCall.ReturnError(ctx, convertError(rerr)); err != nil {
199 fmt.Println("failed to return error:", err, "\noriginal error:", rerr)
200 }
201 }
202 }()
203
204 parentName, err := fnCall.ParentName(ctx)
205 if err != nil {
206 return fmt.Errorf("get parent name: %w", err)
207 }
208 fnName, err := fnCall.Name(ctx)
209 if err != nil {
210 return fmt.Errorf("get fn name: %w", err)
211 }
212 parentJson, err := fnCall.Parent(ctx)
213 if err != nil {
214 return fmt.Errorf("get fn parent: %w", err)
215 }
216 fnArgs, err := fnCall.InputArgs(ctx)
217 if err != nil {
218 return fmt.Errorf("get fn args: %w", err)
219 }
220
221 inputArgs := map[string][]byte{}
222 for _, fnArg := range fnArgs {
223 argName, err := fnArg.Name(ctx)
224 if err != nil {
225 return fmt.Errorf("get fn arg name: %w", err)
226 }
227 argValue, err := fnArg.Value(ctx)
228 if err != nil {
229 return fmt.Errorf("get fn arg value: %w", err)
230 }
231 inputArgs[argName] = []byte(argValue)
232 }
233
234 result, err := invoke(ctx, []byte(parentJson), parentName, fnName, inputArgs)
235 if err != nil {
236 return err
237 }
238 resultBytes, err := json.Marshal(result)
239 if err != nil {

Callers 1

mainFunction · 0.70

Calls 15

setMarshalContextFunction · 0.70
convertErrorFunction · 0.70
invokeFunction · 0.70
StringMethod · 0.65
CloseMethod · 0.65
CurrentFunctionCallMethod · 0.65
NameMethod · 0.65
ValueMethod · 0.65
MarshalMethod · 0.65
ReturnErrorMethod · 0.45
ParentNameMethod · 0.45
ParentMethod · 0.45

Tested by

no test coverage detected