spark-server/.cursor/rules/tcp-eventloop.mdc
2026-09-16 19:08:06 +08:00

22 lines
880 B
Plaintext

---
description: gnet EventLoop rules for the TCP transport.
globs: internal/transport/tcp/**/*.go
alwaysApply: false
---
# TCP / gnet
EventLoop may: parse PROXY (before TLS), TLS, decode Frame, heartbeat, PUSH_ACK, rate-limit check, `TaskPool.Submit`, `AsyncWrite`.
EventLoop must not: MySQL, Redis, upload, group member expand, deliver fanout.
Heartbeat / PUSH_ACK stay in the loop. `AUTH` / `SEND_MESSAGE` / `SYNC_*` / `READ` / `RECALL` go to TaskPool.
`TaskPool` is a bounded channel. Full → `errs.ErrBusy`, client retries with the same `client_msg_id`. Do not block `OnTraffic` on MySQL.
Business modules send via `session.Manager`, never `gnet.Conn`.
Same `device_id` kicks the old connection. Do not close a connection solely because PUSH_ACK timed out.
gnet options: Multicore, 16MB buffers, TCPKeepAlive 30s. IdleTimeout 120s. Align with Nginx `proxy_timeout`.