picoclaw/pkg/channels
Hoshina afc7a1988f refactor(bus): fix deadlock and concurrency issues in MessageBus
PublishInbound/PublishOutbound held RLock during blocking channel sends,
deadlocking against Close() which needs a write lock when the buffer is
full. ConsumeInbound/SubscribeOutbound used bare receives instead of
comma-ok, causing zero-value processing or busy loops after close.

Replace sync.RWMutex+bool with atomic.Bool+done channel so Publish
methods use a lock-free 3-way select (send / done / ctx.Done). Add
context.Context parameter to both Publish methods so callers can cancel
or timeout blocked sends. Close() now only sets the atomic flag and
closes the done channel—never closes the data channels—eliminating
send-on-closed-channel panics.

- Remove dead code: RegisterHandler, GetHandler, handlers map,
  MessageHandler type (zero callers across the whole repo)
- Add ErrBusClosed sentinel error
- Update all 10 caller sites to pass context
- Add msgBus.Close() to gateway and agent shutdown flows
- Add pkg/bus/bus_test.go with 11 test cases covering basic round-trip,
  context cancellation, closed-bus behavior, concurrent publish+close,
  full-buffer timeout, and idempotent Close
2026-02-23 00:44:45 +08:00
..
dingtalk refactor(channels): unify message splitting and add per-channel worker queues 2026-02-22 22:46:29 +08:00
discord refactor(media): add MediaStore for unified media file lifecycle management 2026-02-22 23:27:55 +08:00
feishu refactor(bus,channels): promote peer and messageID from metadata to structured fields 2026-02-22 21:57:12 +08:00
line refactor(media): add MediaStore for unified media file lifecycle management 2026-02-22 23:27:55 +08:00
maixcam refactor(channels): unify Start/Stop lifecycle and fix goroutine/context leaks 2026-02-22 22:25:07 +08:00
onebot refactor(media): add MediaStore for unified media file lifecycle management 2026-02-22 23:27:55 +08:00
qq refactor(bus,channels): promote peer and messageID from metadata to structured fields 2026-02-22 21:57:12 +08:00
slack refactor(media): add MediaStore for unified media file lifecycle management 2026-02-22 23:27:55 +08:00
telegram refactor(media): add MediaStore for unified media file lifecycle management 2026-02-22 23:27:55 +08:00
wecom refactor(channels): unify message splitting and add per-channel worker queues 2026-02-22 22:46:29 +08:00
whatsapp refactor(channels): unify message splitting and add per-channel worker queues 2026-02-22 22:46:29 +08:00
base.go refactor(bus): fix deadlock and concurrency issues in MessageBus 2026-02-23 00:44:45 +08:00
base_test.go style: fix gofmt formatting (CRLF -> LF) 2026-02-14 11:21:47 +09:00
errors.go refactor(channels): add per-channel rate limiting and send retry with error classification 2026-02-22 23:51:55 +08:00
errors_test.go refactor(channels): add per-channel rate limiting and send retry with error classification 2026-02-22 23:51:55 +08:00
manager.go refactor(channels): add per-channel rate limiting and send retry with error classification 2026-02-22 23:51:55 +08:00
manager_test.go refactor(channels): add per-channel rate limiting and send retry with error classification 2026-02-22 23:51:55 +08:00
registry.go refactor(channels): add factory registry and export SetRunning on BaseChannel 2026-02-20 23:18:46 +08:00