MCPcopy Create free account
hub / github.com/buggregator/server / HandleConnection

Method HandleConnection

modules/monolog/handler.go:17–59  ·  view source on GitHub ↗
(conn net.Conn)

Source from the content-addressed store, hash-verified

15}
16
17func (h *tcpHandler) HandleConnection(conn net.Conn) {
18 defer conn.Close()
19
20 scanner := bufio.NewScanner(conn)
21 scanner.Buffer(make([]byte, 0, 64*1024), 10*1024*1024) // 10MB max
22
23 for scanner.Scan() {
24 line := scanner.Bytes()
25 if len(line) == 0 {
26 continue
27 }
28
29 var payload map[string]any
30 if err := json.Unmarshal(line, &payload); err != nil {
31 slog.Debug("monolog: invalid JSON", "err", err)
32 continue
33 }
34
35 // Extract project from context.
36 project := ""
37 if ctx, ok := payload["context"].(map[string]any); ok {
38 if p, ok := ctx["project"].(string); ok {
39 project = p
40 }
41 }
42
43 b, _ := json.Marshal(payload)
44
45 inc := &event.Incoming{
46 Type: "monolog",
47 Payload: json.RawMessage(b),
48 Project: project,
49 }
50
51 if err := h.eventService.HandleIncoming(context.Background(), inc); err != nil {
52 slog.Error("monolog: failed to store event", "err", err)
53 }
54 }
55
56 if err := scanner.Err(); err != nil {
57 slog.Debug("monolog: connection error", "err", err)
58 }
59}

Callers

nothing calls this directly

Calls 2

ScanMethod · 0.80
HandleIncomingMethod · 0.65

Tested by

no test coverage detected