Improved Handling of Unknown EventKind
in EventIterator
#102
Labels
good first issue
Good for newcomers
EventKind
in EventIterator
#102
Description
EventIterator
currently navigates through events stored inEventDb
, deserializing them based on theirEventKind
. When encountering anEventKind
not present in theEventKind
enum,EventIterator::next
returnsSome(Err(InvalidEvent::Key(k)))
.This behavior can cause issues when a review agent sends a new type of event that's not represented in the
EventKind
enum and stores it in the database. We need to enhanceEventIterator
's handling of unknown event kinds to ensure smooth processing.Current Implementation
The current implementation extracts and checks the event kind as follows:
Suggested Enhancement
Instead of returning
Some(Err(InvalidEvent::Key(k)))
for unknown event kinds, we propose a change whereEventIterator
logs a warning message and continues to retrieve the next events until a valid event type is encountered. This approach avoids interrupting the iteration process due to unknown event kinds.The updated implementation is as follows:
In this approach,
EventIterator::next()
continues to fetch the next event until it finds a valid event type. Upon encountering an unknown event kind, it logs a warning and continues the loop until it finds a known event type or there are no more events to iterate over.Benefits
This improvement enhances
EventIterator
's resilience against unknown event kinds, ensuring the iteration process remains uninterrupted even with the introduction of new, currently unknown event kinds. The change increases overall robustness and eases the integration of new event kinds in the future.The text was updated successfully, but these errors were encountered: