MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / encode_v1_batch

Method encode_v1_batch

crates/client-api/src/routes/subscribe.rs:1492–1516  ·  view source on GitHub ↗

Encode a batch for the original v1 websocket protocols. v1 text/binary messages are encoded one logical message at a time. This path also handles reducer errors, which still use the v1 message schema.

(
        &mut self,
        message_batch: &mut Vec<OutboundWsMessage>,
    )

Source from the content-addressed store, hash-verified

1490 /// v1 text/binary messages are encoded one logical message at a time. This
1491 /// path also handles reducer errors, which still use the v1 message schema.
1492 async fn encode_v1_batch(
1493 &mut self,
1494 message_batch: &mut Vec<OutboundWsMessage>,
1495 ) -> Result<(), mpsc::error::SendError<Frame>> {
1496 for message in message_batch.drain(..) {
1497 match message {
1498 OutboundWsMessage::Error(message) => {
1499 self.encode_and_forward_v1_message(None, message).await?;
1500 }
1501 OutboundWsMessage::Message(message) => {
1502 let num_rows = message.num_rows();
1503 match message {
1504 OutboundMessage::V2(_) => {
1505 log::error!("dropping v2 message on v1 connection");
1506 continue;
1507 }
1508 OutboundMessage::V1(message) => {
1509 self.encode_and_forward_v1_message(num_rows, message).await?;
1510 }
1511 }
1512 }
1513 }
1514 }
1515 Ok(())
1516 }
1517
1518 /// Encode a batch for protocol v2.
1519 ///

Callers 1

encode_batchMethod · 0.80

Calls 4

drainMethod · 0.80
OkFunction · 0.50
num_rowsMethod · 0.45

Tested by

no test coverage detected