MCPcopy Create free account
hub / github.com/encodeous/nylon / SendIPCRequest

Function SendIPCRequest

core/ipc_client.go:11–48  ·  view source on GitHub ↗
(itf string, req *protocol.IpcRequest)

Source from the content-addressed store, hash-verified

9)
10
11func SendIPCRequest(itf string, req *protocol.IpcRequest) (*protocol.IpcResponse, error) {
12 conn, err := ipc.UAPIDial(itf)
13 if err != nil {
14 return nil, fmt.Errorf("connect to %s: %w", itf, err)
15 }
16 defer conn.Close()
17
18 rw := bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn))
19
20 if _, err := rw.WriteString("get=nylon\n"); err != nil {
21 return nil, err
22 }
23
24 data, err := pjMarshal.Marshal(req)
25 if err != nil {
26 return nil, err
27 }
28 if _, err := rw.Write(data); err != nil {
29 return nil, err
30 }
31 if _, err := rw.WriteString("\n"); err != nil {
32 return nil, err
33 }
34 if err := rw.Flush(); err != nil {
35 return nil, err
36 }
37
38 line, err := rw.ReadBytes('\n')
39 if err != nil {
40 return nil, fmt.Errorf("read response: %w", err)
41 }
42
43 resp := &protocol.IpcResponse{}
44 if err := pjUnmarshal.Unmarshal(line, resp); err != nil {
45 return nil, fmt.Errorf("unmarshal response: %w", err)
46 }
47 return resp, nil
48}
49
50func SendIPCStream(itf string, req *protocol.IpcRequest, handler func(*protocol.IpcResponse) error) error {
51 conn, err := ipc.UAPIDial(itf)

Callers 3

status.goFile · 0.92
probe.goFile · 0.92
reload.goFile · 0.92

Calls 4

UAPIDialFunction · 0.92
FlushMethod · 0.80
CloseMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected