MCPcopy Create free account
hub / github.com/asternic/wuzapi / Start

Method Start

stdio.go:135–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

133}
134
135func (ss *stdioServer) Start() error {
136 log.Info().Msg("Starting stdio mode - reading JSON requests from stdin")
137
138 scanner := bufio.NewScanner(ss.stdin)
139
140 const maxCapacity = 512 * 1024 // 512KB
141 buf := make([]byte, maxCapacity)
142 scanner.Buffer(buf, maxCapacity)
143
144 for scanner.Scan() {
145 line := scanner.Bytes()
146 if len(line) == 0 {
147 continue // Skip empty lines
148 }
149 ss.handleRequest(line)
150 }
151
152 // Scanner stopped, check why
153 if err := scanner.Err(); err != nil {
154 log.Error().Err(err).Msg("Error reading from stdin")
155 return err
156 }
157
158 log.Info().Msg("EOF reached on stdin, shutting down")
159 return nil
160}
161
162func (ss *stdioServer) handleRequest(requestBytes []byte) {
163 var req jsonRpcRequest

Callers 2

executeRequestFunction · 0.80
startStdioModeFunction · 0.80

Calls 1

handleRequestMethod · 0.95

Tested by 1

executeRequestFunction · 0.64