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

Method Call

core/modfunc.go:816–943  ·  view source on GitHub ↗
(ctx context.Context, opts *CallOpts)

Source from the content-addressed store, hash-verified

814}
815
816func (fn *ModuleFunction) Call(ctx context.Context, opts *CallOpts) (t dagql.AnyResult, rerr error) {
817 mod := fn.mod.Self()
818
819 lg := bklog.G(ctx).WithField("module", mod.Name()).WithField("function", fn.metadata.Name)
820 if fn.objDef != nil {
821 lg = lg.WithField("object", fn.objDef.Name)
822 }
823 ctx = bklog.WithLogger(ctx, lg)
824
825 // Capture analytics for the function call.
826 // Calls without function name are internal and excluded.
827 fn.recordCall(ctx)
828
829 curCall := dagql.CurrentCall(ctx)
830 execMD := engineutil.ExecutionMetadata{
831 Internal: true,
832 }
833 if curCall != nil {
834 callDigest, err := curCall.RecipeDigest(ctx)
835 if err != nil {
836 return nil, fmt.Errorf("compute function exec call digest: %w", err)
837 }
838 execMD.CallDigest = callDigest
839 }
840
841 callInputs, err := fn.setCallInputs(ctx, opts)
842 if err != nil {
843 return nil, fmt.Errorf("set call inputs: %w", err)
844 }
845
846 bklog.G(ctx).Debug("function call")
847 defer func() {
848 bklog.G(ctx).Debug("function call done")
849 if rerr != nil {
850 bklog.G(ctx).WithError(rerr).Error("function call errored")
851 }
852 }()
853
854 parentJSON, err := json.Marshal(opts.ParentFields)
855 if err != nil {
856 return nil, fmt.Errorf("marshal parent value: %w", err)
857 }
858
859 fnCall := newFunctionCall(FunctionCall{
860 Name: fn.metadata.OriginalName,
861 Parent: parentJSON,
862 InputArgs: callInputs,
863 })
864 if fn.objDef != nil {
865 fnCall.ParentName = fn.objDef.OriginalName
866 }
867
868 var envContext dagql.ObjectResult[*Env]
869 if env, ok, err := EnvFromContext(ctx); err != nil {
870 return nil, fmt.Errorf("resolve function env context: %w", err)
871 } else if ok {
872 envContext = env
873 }

Callers

nothing calls this directly

Calls 15

recordCallMethod · 0.95
setCallInputsMethod · 0.95
loadFunctionRuntimeMethod · 0.95
hasWorkspaceArgsMethod · 0.95
DigestMethod · 0.95
WithLoggerFunction · 0.92
CurrentCallFunction · 0.92
WithSkipFunction · 0.92
newFunctionCallFunction · 0.85
EnvFromContextFunction · 0.85
NewCollectedContentFunction · 0.85

Tested by

no test coverage detected