- Add comprehensive 8-phase implementation plan (docs/plan.md) - Add 28 Architecture Decision Records (docs/adr/) covering all phases - Add task tracking system with 283+ task files (docs/stories/) - Add task generator script for automated task file creation - Add reference playbooks and requirements documentation This commit establishes the complete planning foundation for the Go Platform implementation, documenting all architectural decisions and providing detailed task breakdown for Phases 0-8.
60 lines
1.8 KiB
Markdown
60 lines
1.8 KiB
Markdown
# ADR-0023: Event Bus Implementation
|
|
|
|
## Status
|
|
Accepted
|
|
|
|
## Context
|
|
The platform needs an event bus for:
|
|
- Module-to-module communication
|
|
- Decoupled event publishing
|
|
- Event sourcing (optional, future)
|
|
- Integration with external systems
|
|
|
|
Options considered:
|
|
1. **In-process channel-based bus** - Simple, for development/testing
|
|
2. **Kafka** - Production-grade, scalable
|
|
3. **RabbitMQ** - Alternative message broker
|
|
4. **Redis pub/sub** - Simple but less reliable
|
|
|
|
## Decision
|
|
Support **dual implementation** with **in-process primary, Kafka for production**:
|
|
|
|
1. **In-process bus (default)**:
|
|
- Channel-based implementation
|
|
- Used for development, testing, small deployments
|
|
- Simple, no external dependencies
|
|
|
|
2. **Kafka bus (production)**:
|
|
- Full Kafka integration via `segmentio/kafka-go`
|
|
- Producer/consumer groups
|
|
- Configurable via environment (switch implementation)
|
|
|
|
**Rationale:**
|
|
- In-process bus is simple for development
|
|
- Kafka provides production-grade reliability and scalability
|
|
- Interface abstraction allows swapping
|
|
- Modules don't need to know which implementation
|
|
- Can start simple and scale up
|
|
|
|
## Consequences
|
|
|
|
### Positive
|
|
- Simple for development (no Kafka needed)
|
|
- Scalable for production (Kafka)
|
|
- Flexible (can choose implementation)
|
|
- Modules are decoupled from implementation
|
|
|
|
### Negative
|
|
- Two implementations to maintain
|
|
- Need to ensure interface covers both use cases
|
|
- Kafka adds infrastructure complexity
|
|
|
|
### Implementation Notes
|
|
- Create `pkg/eventbus/eventbus.go` interface
|
|
- Implement `internal/infra/bus/inprocess_bus.go` (channel-based)
|
|
- Implement `internal/infra/bus/kafka_bus.go` (Kafka)
|
|
- Select implementation via config
|
|
- Support both sync and async event publishing
|
|
- Handle errors gracefully (retry, dead letter queue)
|
|
|