MCPcopy Create free account
hub / github.com/wavetermdev/waveterm / GenMethod_ResponseStream

Function GenMethod_ResponseStream

pkg/gogen/gogen.go:97–107  ·  view source on GitHub ↗
(buf *strings.Builder, methodDecl *wshrpc.WshRpcMethodDecl)

Source from the content-addressed store, hash-verified

95}
96
97func GenMethod_ResponseStream(buf *strings.Builder, methodDecl *wshrpc.WshRpcMethodDecl) {
98 fmt.Fprintf(buf, "// command %q, wshserver.%s\n", methodDecl.Command, methodDecl.MethodName)
99 dataType, dataVarName := getWshMethodDataParamsAndExpr(methodDecl)
100 respType := "any"
101 if methodDecl.DefaultResponseDataType != nil {
102 respType = methodDecl.DefaultResponseDataType.String()
103 }
104 fmt.Fprintf(buf, "func %s(w *wshutil.WshRpc%s, opts *wshrpc.RpcOpts) chan wshrpc.RespOrErrorUnion[%s] {\n", methodDecl.MethodName, dataType, respType)
105 fmt.Fprintf(buf, "\treturn sendRpcRequestResponseStreamHelper[%s](w, %q, %s, opts)\n", respType, methodDecl.Command, dataVarName)
106 fmt.Fprintf(buf, "}\n\n")
107}
108
109func getWshMethodDataParamsAndExpr(methodDecl *wshrpc.WshRpcMethodDecl) (string, string) {
110 dataTypes := methodDecl.GetCommandDataTypes()

Callers 1

GenerateWshClientFunction · 0.92

Calls 2

StringMethod · 0.45

Tested by

no test coverage detected