MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / dispatchResult

Method dispatchResult

backend/daemon.go:198–368  ·  view source on GitHub ↗
(ctx context.Context, client *wsClient, req RPCRequest)

Source from the content-addressed store, hash-verified

196 return err
197 }
198 actualPort := listener.Addr().(*net.TCPAddr).Port
199 server := &DaemonServer{
200 opts: opts,
201 token: token,
202 clients: map[*wsClient]struct{}{},
203 upgrader: websocket.Upgrader{CheckOrigin: func(r *http.Request) bool {
204 return r.Host == r.URL.Host || strings.HasPrefix(r.RemoteAddr, "127.0.0.1:") || strings.HasPrefix(r.RemoteAddr, "[::1]:")
205 }},
206 }
207 server.manager = NewSessionManager(opts.Config, server.broadcast)
208 server.teamManager = luminateam.NewManager(opts.Config, func(parentSessionID, eventType string, payload any) {
209 server.broadcast(PushEvent{
210 Type: "event",
211 SessionID: parentSessionID,
212 Seq: time.Now().UnixNano(),
213 Event: map[string]any{
214 "type": eventType,
215 "payload": payload,
216 },
217 })
218 }, nil)
219 mux := http.NewServeMux()
220 mux.HandleFunc("/v1/ws", server.handleWS)
221 mux.HandleFunc("/v1/a2a/ws", server.handleA2AWS)
222 mux.HandleFunc("/healthz", func(w http.ResponseWriter, _ *http.Request) {
223 _, _ = w.Write([]byte("ok"))
224 })
225 server.httpSrv = &http.Server{Handler: mux}
226 endpoint := EndpointInfo{
227 PID: os.Getpid(),
228 Host: opts.Host,
229 Port: actualPort,
230 AuthToken: token,
231 StartedAt: nowRFC3339(),
232 URL: fmt.Sprintf("ws://%s:%d/v1/ws", opts.Host, actualPort),
233 }
234 if err := writeEndpoint(opts.EndpointPath, endpoint); err != nil {
235 _ = listener.Close()
236 return err
237 }
238 server.startManagedServices()
239 defer server.shutdownManagedResources()
240 go func() {
241 <-ctx.Done()
242 _ = server.httpSrv.Shutdown(context.Background())
243 }()
244 go server.startIdleHeartbeat(ctx)
245 fmt.Fprintf(os.Stderr, "lumina-backend daemon listening on %s:%d\n", opts.Host, actualPort)
246 err = server.httpSrv.Serve(listener)
247 if err == http.ErrServerClosed {
248 return nil
249 }
250 return err
251}
252
253func (s *DaemonServer) startManagedServices() {
254 if path := s.searxNGScriptPath(); path != "" {
255 if output, err := runManagedScript(path, "start", s.opts.Config); err != nil {

Callers 1

dispatchMethod · 0.95

Calls 15

controllerFromParamsMethod · 0.95
clientCountExcludingMethod · 0.95
optionalControllerMethod · 0.95
decodeParamsFunction · 0.85
toRPCErrorFunction · 0.85
CountMethod · 0.80
CreateMethod · 0.80
setSessionIDMethod · 0.80
IDMethod · 0.80
SnapshotMethod · 0.80
ResumeMethod · 0.80
ListMethod · 0.80

Tested by

no test coverage detected