refactor(grpc/client): simplify processEventStream with per-event handlers

- Extract eventHandlers dispatch table
- Add per-event handlers: handleSlugChange, handleGetSessions, handleTerminateSession
- Introduce sendNode helper to centralize send/error handling and preserve connection-error propagation
- Add protoToTunnelType for tunnel-type validation
- Map unknown proto.TunnelType to types.UNKNOWN in protoToTunnelType and return a descriptive error
- Reduce boilerplate and improve readability of processEventStream
This commit is contained in:
2026-01-06 20:14:56 +07:00
parent bef7a49f88
commit 887ebf78b1
2 changed files with 141 additions and 193 deletions
+3 -2
View File
@@ -11,8 +11,9 @@ const (
type TunnelType string
const (
HTTP TunnelType = "HTTP"
TCP TunnelType = "TCP"
UNKNOWN TunnelType = "UNKNOWN"
HTTP TunnelType = "HTTP"
TCP TunnelType = "TCP"
)
type SessionKey struct {