MCPcopy
hub / github.com/wavetermdev/waveterm / MakeWshRpcWithChannels

Function MakeWshRpcWithChannels

pkg/wshutil/wshrpc.go:215–239  ·  view source on GitHub ↗

closes outputCh when inputCh is closed/done

(inputCh chan baseds.RpcInputChType, outputCh chan []byte, rpcCtx wshrpc.RpcContext, serverImpl ServerImpl, debugName string)

Source from the content-addressed store, hash-verified

213
214// closes outputCh when inputCh is closed/done
215func MakeWshRpcWithChannels(inputCh chan baseds.RpcInputChType, outputCh chan []byte, rpcCtx wshrpc.RpcContext, serverImpl ServerImpl, debugName string) *WshRpc {
216 if inputCh == nil {
217 inputCh = make(chan baseds.RpcInputChType, DefaultInputChSize)
218 }
219 if outputCh == nil {
220 outputCh = make(chan []byte, DefaultOutputChSize)
221 }
222 validateServerImpl(serverImpl)
223 rtn := &WshRpc{
224 Lock: &sync.Mutex{},
225 DebugName: debugName,
226 InputCh: inputCh,
227 OutputCh: outputCh,
228 CtxDoneCh: make(chan string, CtxDoneChSize),
229 RpcMap: make(map[string]*rpcData),
230 RpcContext: &atomic.Pointer[wshrpc.RpcContext]{},
231 EventListener: MakeEventListener(),
232 ServerImpl: serverImpl,
233 ResponseHandlerMap: make(map[string]*RpcResponseHandler),
234 }
235 rtn.RpcContext.Store(&rpcCtx)
236 rtn.StreamBroker = streamclient.NewBroker(AdaptWshRpc(rtn))
237 go rtn.runServer()
238 return rtn
239}
240
241func MakeWshRpc(rpcCtx wshrpc.RpcContext, serverImpl ServerImpl, debugName string) *WshRpc {
242 return MakeWshRpcWithChannels(nil, nil, rpcCtx, serverImpl, debugName)

Callers 4

MakeWshRpcFunction · 0.85
SetupPacketRpcClientFunction · 0.85
SetupConnRpcClientFunction · 0.85

Calls 5

runServerMethod · 0.95
NewBrokerFunction · 0.92
validateServerImplFunction · 0.85
MakeEventListenerFunction · 0.85
AdaptWshRpcFunction · 0.85

Tested by

no test coverage detected