Files
pubsub/tasks/004-redis-channel-prefix-and-error-handling.md
glm-5.1 1306716897 Decompose architecture into atomic, dependency-ordered tasks
19 tasks covering core testing, Redis hardening, WebSocket client/server
adapters, Worker adapter, and final review gates. Iroh adapters are tracked
as a deferred placeholder blocked on the @alkdev/iroh fork.

Phases: core validation → Redis hardening → review gate → WebSocket
adapters → review gate → Worker adapter → review gate → final validation.
2026-05-08 05:50:43 +00:00

45 lines
1.7 KiB
Markdown

---
id: redis-channel-prefix-and-error-handling
name: Add channel prefix and error handling to Redis event target
status: pending
depends_on: [redis-adapter-tests]
scope: narrow
risk: low
impact: component
level: implementation
---
## Description
The architecture doc for the Redis adapter lists two limitations that need to be addressed:
1. **No channel prefix** — raw event types as channel names risk collision in shared Redis instances. The adapter should support a configurable prefix like `createRedisEventTarget({ ..., prefix: "alk:events:" })`.
2. **No error handling** — connection failures, reconnection, and message parse errors are not handled. The adapter should:
- Handle serializer parse errors gracefully (log warning, skip message)
- Handle subscribe client disconnect gracefully (registered callbacks remain but won't fire)
- Note that in-flight messages after unsubscribe are harmless (empty callback set = no-op)
These are quality-of-life improvements that make the adapter production-ready.
## Acceptance Criteria
- [ ] `CreateRedisEventTargetArgs` accepts an optional `prefix` field (string, default `""`)
- [ ] When `prefix` is set, channel names are prefixed: `"alk:events:call.responded:uuid-123"`
- [ ] Both publish and subscribe use the same prefix convention
- [ ] Malformed messages from Redis (serializer parse errors) are caught and logged, not thrown
- [ ] Existing tests updated to cover prefix behavior
- [ ] New tests for prefix behavior and error handling
## References
- docs/architecture/event-targets/redis.md (Limitations section)
- src/event-target-redis.ts
## Notes
> To be filled by implementation agent
## Summary
> To be filled on completion