Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

corro-client: add expected and received change ID to MissedChange error #244

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions crates/corro-client/src/sub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ pub enum SubscriptionError {
Http(#[from] http::Error),
#[error(transparent)]
Deserialize(#[from] serde_json::Error),
#[error("missed a change, inconsistent state")]
MissedChange,
#[error("missed a change (expected: {expected}, got: {got}), inconsistent state")]
MissedChange { expected: ChangeId, got: ChangeId },
#[error("max line length exceeded")]
MaxLineLengthExceeded,
#[error("initial query never finished")]
Expand Down Expand Up @@ -148,8 +148,14 @@ where
self.last_change_id = *change_id;
}
if let TypedQueryEvent::Change(_, _, _, change_id) = &evt {
if matches!(self.last_change_id, Some(id) if id.0 + 1 != change_id.0) {
return Poll::Ready(Some(Err(SubscriptionError::MissedChange)));
match self.last_change_id {
Some(id) if id + 1 != *change_id => {
return Poll::Ready(Some(Err(SubscriptionError::MissedChange {
expected: id + 1,
got: *change_id,
})))
}
_ => (),
}
self.last_change_id = Some(*change_id);
}
Expand Down
Loading