mirror of
https://github.com/joelhooks/joelclaw.git
synced 2026-09-19 01:24:04 +08:00
b8c1dc3a48
## Overview Extracted generic Redis stream + priority index primitives from @joelclaw/message-store into a new @joelclaw/queue package. This separates the reusable queue mechanics from gateway-specific logic. ## Changes ### New Package: @joelclaw/queue - Generic Redis stream + consumer group management - Priority-based sorted set indexing (P0-P3) - Functions: init(), persist(), ack(), getUnacked(), drainByPriority(), indexMessagesByPriority(), trimOld() - Configurable via QueueConfig (streamKey, priorityKey, consumerGroup, consumerName) - No gateway-specific dedup, classification, or coalescing - Exported via @joelclaw/queue for reuse ### Updated: @joelclaw/message-store (Gateway Adapter) - Now depends on @joelclaw/queue - Preserved public API (init, persist, ack, drainByPriority, etc.) - Retained gateway-specific behaviors: - classifyPriority() for Telegram/iMessage/heartbeat classification - Dedup hashing with 30s window - P0 drain streak (allow lower priority after 3 P0s) - P3 coalescing (combine multiple P3s within 60s) - Channel context stripping - Wraps queue functions for composition ### Testing - message-store: 10 tests passing - queue: 5 tests passing - TypeScript: no errors - Biome: no formatting issues ## Files Created: - packages/queue/package.json - packages/queue/src/index.ts - packages/queue/src/store.ts - packages/queue/src/types.ts - packages/queue/__tests__/store.test.ts Modified: - packages/message-store/package.json - packages/message-store/src/store.ts - packages/message-store/src/types.ts - packages/message-store/src/index.ts - pnpm-lock.yaml ## Architecture This implements hexagonal architecture by: - Moving pure queue mechanics into a reusable interface - Keeping gateway adapters thin (composition, not inheritance) - Enabling future queue consumers (workflows, memory, etc.) without gateway coupling ## Next Steps (ADR-0217 Phase 1 Story 2) - Add queue registry for named queue instances - CLI for queue introspection and management
5 lines
61 B
JSON
5 lines
61 B
JSON
{
|
|
"extends": "../../tsconfig.json",
|
|
"include": ["src"]
|
|
}
|