MCPcopy Index your code
hub / github.com/apache/devlake / Call

Method Call

backend/server/services/remote/bridge/cmd.go:53–87  ·  view source on GitHub ↗
(methodName string, ctx plugin.ExecContext, args ...any)

Source from the content-addressed store, hash-verified

51}
52
53func (c *CmdInvoker) Call(methodName string, ctx plugin.ExecContext, args ...any) *CallResult {
54 serializedArgs, err := serialize(append([]any{DefaultContext.GetRemoteConfig()}, args...)...)
55 if err != nil {
56 return &CallResult{
57 Err: err,
58 }
59 }
60 executable, inputArgs := c.resolveCmd(methodName, serializedArgs...)
61 cmdCtx := DefaultContext.GetContext()
62 cmd := exec.CommandContext(cmdCtx, executable, inputArgs...)
63 if c.workingPath != "" {
64 cmd.Dir = c.workingPath
65 }
66 response, err := utils.RunProcess(cmd, &utils.RunProcessOptions{
67 OnStdout: func(b []byte) {
68 msg := string(b)
69 c.logRemoteMessage(ctx.GetLogger(), msg)
70 },
71 OnStderr: func(b []byte) {
72 msg := string(b)
73 c.logRemoteError(ctx.GetLogger(), msg)
74 },
75 UseFdOut: true,
76 })
77 if err != nil {
78 return NewCallResult(nil, err)
79 }
80 err = response.GetError()
81 if err != nil {
82 return &CallResult{
83 Err: errors.Default.Wrap(err, fmt.Sprintf("get error when invoking remote function %s", methodName)),
84 }
85 }
86 return NewCallResult(response.GetFdOut(), nil)
87}
88
89func (c *CmdInvoker) Stream(methodName string, ctx plugin.ExecContext, args ...any) *MethodStream {
90 recvChannel := make(chan *StreamResult)

Callers 2

LoadRemotePluginsFunction · 0.95
mainFunction · 0.95

Calls 10

logRemoteMessageMethod · 0.95
logRemoteErrorMethod · 0.95
serializeFunction · 0.85
NewCallResultFunction · 0.85
GetErrorMethod · 0.80
WrapMethod · 0.80
GetFdOutMethod · 0.80
GetRemoteConfigMethod · 0.65
GetContextMethod · 0.65
GetLoggerMethod · 0.65

Tested by

no test coverage detected