feat(gateway): scaffold standalone gateway IPC with core.ping#251
feat(gateway): scaffold standalone gateway IPC with core.ping#251fennoai[bot] wants to merge 1 commit into
Conversation
Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: pionxe <148670367+pionxe@users.noreply.github.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
| } | ||
|
|
||
| if err := os.MkdirAll(filepath.Dir(socketPath), 0o755); err != nil { | ||
| return nil, "", fmt.Errorf("create socket dir: %w", err) |
There was a problem hiding this comment.
listenUDS unconditionally removes socketPath before binding. If --endpoint points to an existing non-socket file, this can delete user data unexpectedly. Please guard cleanup with os.Lstat and only remove stale socket files (ModeSocket).
| return closeErr | ||
| } | ||
|
|
||
| // handleConn 按消息粒度解码请求并写回响应。 |
There was a problem hiding this comment.
Connection handling currently has no read deadline or payload size cap, so a slow client or oversized JSON can hold goroutines/fds indefinitely and cause local DoS. Please add idle/read timeout and max request size enforcement (for example limited reader + decode checks).
| }() | ||
|
|
||
| for { | ||
| conn, err := s.listener.Accept() |
There was a problem hiding this comment.
Each accepted connection is handled in a new goroutine with no concurrency limit/backpressure. Under bursty or malicious local traffic this can grow unbounded. Consider a bounded worker/semaphore to cap concurrent active connections.
|
|
||
| // main 负责启动独立 Gateway 进程并监听本地 IPC 请求。 | ||
| func main() { | ||
| transportMode := flag.String("transport", "auto", "IPC transport mode: auto|npipe|uds") |
There was a problem hiding this comment.
This PR adds a new runnable binary and flags (neocode-gateway, --transport, --endpoint) but does not update user-facing docs. Per repo rules, please add README/docs entries for startup command and platform-specific default endpoints.
Requested by @pionxe
Implement EPIC-GW-01 step 1 by adding a standalone
neocode-gatewayprocess skeleton and local IPC JSON-RPC contract.Summary
cmd/neocode-gatewayentrypoint with-transport(auto|npipe|uds) and-endpointflags.internal/gateway/bootstrap.go.internal/gateway/transport:server.goaccept loop + JSON message handlinguds_unix.goUnix socket listener + socket cleanupnpipe_windows.goWindows named pipe listenerinternal/gateway/protocol/jsonrpc.go.core.ping -> Ponghandler ininternal/gateway/handlers/ping.go.internal/gateway/adapters/core_mock.go.go.mod/go.sumto include Windows named pipe dependency (github.com/natefinch/npipe).Tests
internal/gateway/bootstrap_test.go.gofmt -w ./cmd ./internalgo test ./...Closes #250