feat: round-5 abstractions — BatchProcessor, CircuitBreakerHealthCheck, TypedKeyRegistry, MetricsHttpHandler
This commit is contained in:
@@ -5,29 +5,28 @@
|
||||
## New Features
|
||||
|
||||
### 1. CircuitBreakerHealthCheck (mytheclipse-core, observability+resiliency)
|
||||
File: `crates/mytheclipse/src/metrics_bridge.rs`
|
||||
- `CircuitBreakerHealthCheck` — `HealthCheck` impl that maps `CircuitBreaker::snapshot().state` to HealthStatus:
|
||||
- Open → Unhealthy
|
||||
- HalfOpen → Degraded
|
||||
- Closed → Ok
|
||||
- Gated `#[cfg(feature = "resiliency")]`; re-exported when both observability+resiliency enabled
|
||||
- Feature interaction: `observability` now implies `lifecycle` (needed for `crate::health::{HealthCheck, HealthStatus}`)
|
||||
- `CircuitBreakerHealthCheck` di metrics_bridge.rs — HealthCheck impl yang memetakan CircuitBreaker snapshot state → HealthStatus (Open→Unhealthy, HalfOpen→Degraded, Closed→Ok)
|
||||
- Gated `#[cfg(feature="resiliency")]`; re-export gated `#[cfg(all(observability, resiliency))]`
|
||||
- `observability` feature now implies `lifecycle` (needed for crate::health module access)
|
||||
|
||||
### 2. TypedKeyRegistry (mytheclipse-crypto, password)
|
||||
File: `crates/mytheclipse-crypto/src/key_registry.rs`
|
||||
- `TypedKeyRegistry<K, V>` — registry keyed by string ID, wraps KeyRing for current/previous rotation
|
||||
- `key_for(&self, id: &str) -> Option<&K>` typed lookup
|
||||
- `rotate_with_id(&mut self, id, key)` + `revoke(id)`
|
||||
- Default impl uses String keys (v4 signers)
|
||||
- `TypedKeyRegistry<K,V>` di key_registry.rs — ID-based key lookup + rotation + revoke, wraps KeyRing
|
||||
- `key_for(id) -> Option<&K>`, `rotate_with_id(id, key)`, `revoke(id)`
|
||||
|
||||
### 3. MetricsHttpHandler (mytheclipse-http, metrics-http)
|
||||
File: `crates/mytheclipse-http/src/metrics_http.rs`
|
||||
- new feature `metrics-http` (axum + tower + mytheclipse/observability)
|
||||
- `metrics_routes(collector) -> Router` serving `/metrics` (Prometheus text via `export_prometheus`) + `/`
|
||||
- `tower` dep added (util feature)
|
||||
- `metrics_routes(collector)` → Router serving /metrics (Prometheus text) + /
|
||||
- added tower dep (util), ServiceExt import in test module
|
||||
- 1 test via ServiceExt::oneshot
|
||||
|
||||
### 4. BatchProcessor (mytheclipse-queue, in-memory)
|
||||
- `BatchJobHandler` trait — handle Vec<Job> atomically
|
||||
- `BatchConfig` { batch_size, batch_timeout, concurrency }
|
||||
- `BatchProcessor<Q>` — accumulates jobs per topic, flushes on size/timeout
|
||||
- 2 tests: flush_on_batch_size, flush_on_timeout
|
||||
|
||||
## Verification
|
||||
- `cargo build --workspace --all-features` → exit 0
|
||||
- `cargo test --workspace --all-features` → all pass (160+ tests)
|
||||
- `cargo clippy --workspace --all-features` → no new warnings
|
||||
- cargo build --workspace --all-features → exit 0
|
||||
- cargo test --workspace --all-features → all pass (160+ tests)
|
||||
- cargo clippy --workspace --all-features → no new warnings
|
||||
- commit + push: f02a1ce
|
||||
|
||||
Reference in New Issue
Block a user