Skip to content
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
17 changes: 11 additions & 6 deletions sdks/rust/src/db_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,13 @@ impl<M: SpacetimeModule> DbContextImpl<M> {

/// Apply all queued [`PendingMutation`]s.
fn apply_pending_mutations(&self) -> crate::Result<()> {
while let Ok(Some(pending_mutation)) = get_lock_sync(&self.pending_mutations_recv).try_next() {
self.apply_mutation(pending_mutation)?;
while let Ok(Some(mutation)) = get_lock_sync(&self.pending_mutations_recv).try_next() {
match self.apply_mutation(mutation) {
Err(crate::Error::Disconnected) => {
return Err(self.end_connection(None));
}
result => result?,
}
}

Ok(())
Expand All @@ -386,7 +391,7 @@ impl<M: SpacetimeModule> DbContextImpl<M> {
.as_mut()
.ok_or(crate::Error::Disconnected)?
.unbounded_send(ws::v2::ClientMessage::Subscribe(msg))
.expect("Unable to send subscribe message: WS sender loop has dropped its recv channel");
.map_err(|_| crate::Error::Disconnected)?;
}
// else, the handle was already cancelled.
}
Expand All @@ -410,7 +415,7 @@ impl<M: SpacetimeModule> DbContextImpl<M> {
.as_mut()
.ok_or(crate::Error::Disconnected)?
.unbounded_send(ws::v2::ClientMessage::Unsubscribe(m))
.expect("Unable to send unsubscribe message: WS sender loop has dropped its recv channel");
.map_err(|_| crate::Error::Disconnected)?;
}
}
}
Expand Down Expand Up @@ -443,7 +448,7 @@ impl<M: SpacetimeModule> DbContextImpl<M> {
.as_mut()
.ok_or(crate::Error::Disconnected)?
.unbounded_send(msg)
.expect("Unable to send reducer call message: WS sender loop has dropped its recv channel");
.map_err(|_| crate::Error::Disconnected)?;
}

// Invoke a procedure: stash its callback, then send the `CallProcedure` WS message.
Expand Down Expand Up @@ -472,7 +477,7 @@ impl<M: SpacetimeModule> DbContextImpl<M> {
.as_mut()
.ok_or(crate::Error::Disconnected)?
.unbounded_send(msg)
.expect("Unable to send procedure call message: WS sender loop has dropped its recv channel");
.map_err(|_| crate::Error::Disconnected)?;
}

// Disconnect: close the connection.
Expand Down
Loading