picoclaw/pkg/channels/pico
LC 6aff5b7ccd
fix(pico): use O(1) session indexing and harden websocket concurrency handling (#1970)
* perf(pico): implement O(1) session lookup for pico connections

- Replace `sync.Map` with `connections` and `sessionConnections`.
- Add `addConnection`, `removeConnection`, `sessionConnectionsSnapshot`, and `takeAllConnections` with `connsMu` for concurrency.
- `broadcastToSession` now dispatches directly to `sessionConnections`.
- Add `newUniqueConnID` to avoid UUID collision/overwrites.
- Ensure `Stop` and `readLoop` use the new helpers for safe cleanup and correct `connCount` updates.

* refactor(pico): replace addConnection with createAndAddConnection for atomic connID generation

* refactor(pico): clear connections in one time to improve perf

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix(pico): keep connCount consistent with connection indexes

* refactor(pico): make connCount a regular int guarded by connsMu

* fix(pico): enforce MaxConnections atomically on registration

* fix(pico): use temporary over-limit error and remove conn counter

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-24 23:25:27 +08:00
..
client.go feat(pico): add pico_client outbound WebSocket channel (#1198) 2026-03-20 20:43:40 +08:00
client_test.go feat(pico): add pico_client outbound WebSocket channel (#1198) 2026-03-20 20:43:40 +08:00
init.go feat(pico): add pico_client outbound WebSocket channel (#1198) 2026-03-20 20:43:40 +08:00
pico.go fix(pico): use O(1) session indexing and harden websocket concurrency handling (#1970) 2026-03-24 23:25:27 +08:00
pico_test.go fix(pico): use O(1) session indexing and harden websocket concurrency handling (#1970) 2026-03-24 23:25:27 +08:00
protocol.go fix: resolve golangci-lint issues in channel system 2026-02-23 05:22:18 +08:00