chore: rename data to doc_state

This commit is contained in:
nathan 2024-12-20 10:22:08 +08:00
parent 971aa6d3e1
commit 011a5b59c9
7 changed files with 9 additions and 6 deletions

View File

@ -217,7 +217,7 @@ pub struct InsertSnapshotParams {
#[validate(custom(function = "validate_not_empty_str"))]
pub object_id: String,
#[validate(custom(function = "validate_not_empty_payload"))]
pub data: Bytes,
pub doc_state: Bytes,
#[validate(custom(function = "validate_not_empty_str"))]
pub workspace_id: String,
pub collab_type: CollabType,

View File

@ -107,7 +107,7 @@ where
user: self.user.clone(),
message,
})
.map_err(|err| RealtimeError::Internal(err.into()))
.map_err(|err| RealtimeError::SendWSMessageFailed(err.to_string()))
}
}

View File

@ -79,6 +79,9 @@ pub enum RealtimeError {
#[error("failed to obtain lease: {0}")]
Lease(Box<dyn std::error::Error + Send + Sync>),
#[error("failed to send ws message: {0}")]
SendWSMessageFailed(String),
}
#[derive(Debug)]

View File

@ -1151,7 +1151,7 @@ impl CollabPersister {
.observe(doc_state_full.len() as f64);
let params = InsertSnapshotParams {
object_id: self.object_id.clone(),
data: doc_state_full.into(),
doc_state: doc_state_full.into(),
workspace_id: self.workspace_id.clone(),
collab_type: self.collab_type.clone(),
};

View File

@ -64,7 +64,7 @@ where
let data = encode_collab.doc_state;
let params = InsertSnapshotParams {
object_id,
data,
doc_state: data,
workspace_id,
collab_type,
};

View File

@ -120,7 +120,7 @@ impl SnapshotControl {
let timestamp = Utc::now();
let snapshot_id = timestamp.timestamp_millis();
let key = collab_snapshot_key(&params.workspace_id, &params.object_id, snapshot_id);
let compressed = zstd::encode_all(params.data.as_ref(), ZSTD_COMPRESSION_LEVEL)?;
let compressed = zstd::encode_all(params.doc_state.as_ref(), ZSTD_COMPRESSION_LEVEL)?;
if let Err(err) = self.s3.put_blob(&key, compressed.into(), None).await {
self.collab_metrics.write_snapshot_failures.inc();
return Err(err);

View File

@ -1304,7 +1304,7 @@ async fn create_collab_snapshot_handler(
.create_snapshot(InsertSnapshotParams {
object_id,
workspace_id,
data,
doc_state: data,
collab_type,
})
.await?;