optimize channel orchestration with errgroup and rate limiter

This commit is contained in:
DBT
2026-02-24 09:34:13 +00:00
parent 4105eeb0db
commit 8f75bb9ed8
4 changed files with 67 additions and 38 deletions

View File

@@ -21,11 +21,13 @@ A recent architecture pass leveraged core Go strengths:
1. **Actor-style process path**
- Process metadata persistence is serialized via async queue (`persistQ`).
- Channel start/stop orchestration uses `errgroup.WithContext` for concurrent + unified cancellation.
2. **Typed Events bus**
- Added generic typed pub/sub bus (`pkg/events/typed_bus.go`).
- Process lifecycle events (start/exit/kill) are now publishable.
3. **Batched log flushing**
- Process logs are flushed by `logWriter` with time/size thresholds to reduce I/O churn.
- Outbound dispatch adds a token-bucket `rate.Limiter` for burst smoothing.
4. **Context hierarchy + cancellation propagation**
- Background exec now uses `exec.CommandContext` with parent `ctx` propagation.
5. **Atomic runtime config snapshot**