-
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Context
During the implementation of multi-stream query patterns (#148), it was noted that projections should handle invalid or corrupted data gracefully. Currently, projections may panic or produce incorrect results if they encounter unexpected data.
Requirements
- Validation: Projections should validate incoming events
- Error Recovery: Continue processing valid events even if some are invalid
- Diagnostics: Report which events failed and why
- Idempotency: Support re-running projections safely
Proposed Solution
pub enum ProjectionError {
InvalidEvent { event_id: EventId, reason: String },
StateCorruption { details: String },
// ...
}
pub struct ProjectionResult<T> {
pub state: T,
pub errors: Vec<ProjectionError>,
pub processed_count: usize,
}
impl<T> ProjectionBuilder<T> {
pub fn with_error_handler<F>(self, handler: F) -> Self
where F: Fn(ProjectionError) + Send + Sync + 'static {
// ...
}
}Benefits
- Resilient to data corruption
- Better debugging and monitoring
- Can process partial data sets
- Production-ready error handling
Tasks
- Design error types for projections
- Add validation to projection functions
- Implement error collection and reporting
- Add recovery strategies (skip, retry, compensate)
- Create tests for error scenarios
- Document error handling patterns
Labels
- enhancement
- error-handling
- production-readiness
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request