mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-04-24 22:57:12 -04:00
Extract protobuf structs from flowy-sync crate (#1425)
* refactor: extract data model from flowy-sync crate * chore: rename lib-infra features
This commit is contained in:
parent
7f6ad504fd
commit
882d5535e6
85 changed files with 270 additions and 344 deletions
36
frontend/rust-lib/Cargo.lock
generated
36
frontend/rust-lib/Cargo.lock
generated
|
@ -861,6 +861,7 @@ dependencies = [
|
||||||
"flowy-derive",
|
"flowy-derive",
|
||||||
"flowy-document",
|
"flowy-document",
|
||||||
"flowy-error",
|
"flowy-error",
|
||||||
|
"flowy-http-model",
|
||||||
"flowy-revision",
|
"flowy-revision",
|
||||||
"flowy-sync",
|
"flowy-sync",
|
||||||
"flowy-test",
|
"flowy-test",
|
||||||
|
@ -927,6 +928,7 @@ dependencies = [
|
||||||
"flowy-document",
|
"flowy-document",
|
||||||
"flowy-error",
|
"flowy-error",
|
||||||
"flowy-folder",
|
"flowy-folder",
|
||||||
|
"flowy-http-model",
|
||||||
"flowy-revision",
|
"flowy-revision",
|
||||||
"flowy-sync",
|
"flowy-sync",
|
||||||
"flowy-test",
|
"flowy-test",
|
||||||
|
@ -965,6 +967,7 @@ dependencies = [
|
||||||
"flowy-derive",
|
"flowy-derive",
|
||||||
"flowy-error",
|
"flowy-error",
|
||||||
"flowy-grid",
|
"flowy-grid",
|
||||||
|
"flowy-http-model",
|
||||||
"flowy-revision",
|
"flowy-revision",
|
||||||
"flowy-sync",
|
"flowy-sync",
|
||||||
"flowy-test",
|
"flowy-test",
|
||||||
|
@ -991,6 +994,17 @@ dependencies = [
|
||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "flowy-http-model"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"flowy-derive",
|
||||||
|
"lib-infra",
|
||||||
|
"md5",
|
||||||
|
"protobuf",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flowy-net"
|
name = "flowy-net"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -1004,6 +1018,7 @@ dependencies = [
|
||||||
"flowy-document",
|
"flowy-document",
|
||||||
"flowy-error",
|
"flowy-error",
|
||||||
"flowy-folder",
|
"flowy-folder",
|
||||||
|
"flowy-http-model",
|
||||||
"flowy-sync",
|
"flowy-sync",
|
||||||
"flowy-user",
|
"flowy-user",
|
||||||
"folder-rev-model",
|
"folder-rev-model",
|
||||||
|
@ -1016,7 +1031,7 @@ dependencies = [
|
||||||
"lib-ws",
|
"lib-ws",
|
||||||
"log",
|
"log",
|
||||||
"nanoid",
|
"nanoid",
|
||||||
"parking_lot 0.11.2",
|
"parking_lot 0.12.1",
|
||||||
"protobuf",
|
"protobuf",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -1036,8 +1051,8 @@ dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"dashmap",
|
"dashmap",
|
||||||
"flowy-error",
|
"flowy-error",
|
||||||
|
"flowy-http-model",
|
||||||
"flowy-revision",
|
"flowy-revision",
|
||||||
"flowy-sync",
|
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"lib-infra",
|
"lib-infra",
|
||||||
"lib-ws",
|
"lib-ws",
|
||||||
|
@ -1055,29 +1070,22 @@ dependencies = [
|
||||||
name = "flowy-sdk"
|
name = "flowy-sdk"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
|
||||||
"bytes",
|
"bytes",
|
||||||
"claim 0.5.0",
|
|
||||||
"color-eyre",
|
|
||||||
"flowy-database",
|
"flowy-database",
|
||||||
"flowy-document",
|
"flowy-document",
|
||||||
"flowy-folder",
|
"flowy-folder",
|
||||||
"flowy-grid",
|
"flowy-grid",
|
||||||
|
"flowy-http-model",
|
||||||
"flowy-net",
|
"flowy-net",
|
||||||
"flowy-revision",
|
"flowy-revision",
|
||||||
"flowy-sync",
|
|
||||||
"flowy-user",
|
"flowy-user",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-util",
|
|
||||||
"grid-rev-model",
|
"grid-rev-model",
|
||||||
"lib-dispatch",
|
"lib-dispatch",
|
||||||
"lib-infra",
|
"lib-infra",
|
||||||
"lib-log",
|
"lib-log",
|
||||||
"lib-ws",
|
"lib-ws",
|
||||||
"log",
|
"parking_lot 0.12.1",
|
||||||
"parking_lot 0.11.2",
|
|
||||||
"protobuf",
|
|
||||||
"serde",
|
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
@ -1092,13 +1100,13 @@ dependencies = [
|
||||||
"dashmap",
|
"dashmap",
|
||||||
"dissimilar",
|
"dissimilar",
|
||||||
"flowy-derive",
|
"flowy-derive",
|
||||||
|
"flowy-http-model",
|
||||||
"folder-rev-model",
|
"folder-rev-model",
|
||||||
"futures",
|
"futures",
|
||||||
"grid-rev-model",
|
"grid-rev-model",
|
||||||
"lib-infra",
|
"lib-infra",
|
||||||
"lib-ot",
|
"lib-ot",
|
||||||
"log",
|
"log",
|
||||||
"md5",
|
|
||||||
"parking_lot 0.12.1",
|
"parking_lot 0.12.1",
|
||||||
"protobuf",
|
"protobuf",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -1164,7 +1172,7 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"nanoid",
|
"nanoid",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"parking_lot 0.11.2",
|
"parking_lot 0.12.1",
|
||||||
"protobuf",
|
"protobuf",
|
||||||
"quickcheck",
|
"quickcheck",
|
||||||
"quickcheck_macros",
|
"quickcheck_macros",
|
||||||
|
@ -1809,7 +1817,7 @@ dependencies = [
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"lib-infra",
|
"lib-infra",
|
||||||
"log",
|
"log",
|
||||||
"parking_lot 0.11.2",
|
"parking_lot 0.12.1",
|
||||||
"paste",
|
"paste",
|
||||||
"pin-project",
|
"pin-project",
|
||||||
"protobuf",
|
"protobuf",
|
||||||
|
|
|
@ -38,6 +38,5 @@ openssl_vendored = ["flowy-sdk/openssl_vendored"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = [
|
lib-infra = { path = "../../../shared-lib/lib-infra", features = [
|
||||||
"protobuf_file_gen",
|
|
||||||
"dart",
|
"dart",
|
||||||
] }
|
] }
|
||||||
|
|
|
@ -19,4 +19,4 @@ lib-dispatch = {path = "../lib-dispatch" }
|
||||||
dart = ["lib-infra/dart"]
|
dart = ["lib-infra/dart"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen"] }
|
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["proto_gen"] }
|
|
@ -8,6 +8,7 @@ edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
flowy-sync = { path = "../../../shared-lib/flowy-sync"}
|
flowy-sync = { path = "../../../shared-lib/flowy-sync"}
|
||||||
|
flowy-http-model = { path = "../../../shared-lib/flowy-http-model"}
|
||||||
flowy-derive = { path = "../../../shared-lib/flowy-derive" }
|
flowy-derive = { path = "../../../shared-lib/flowy-derive" }
|
||||||
lib-ot = { path = "../../../shared-lib/lib-ot" }
|
lib-ot = { path = "../../../shared-lib/lib-ot" }
|
||||||
lib-ws = { path = "../../../shared-lib/lib-ws" }
|
lib-ws = { path = "../../../shared-lib/lib-ws" }
|
||||||
|
@ -51,7 +52,7 @@ criterion = "0.3"
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen", "proto_gen"] }
|
lib-infra = { path = "../../../shared-lib/lib-infra", features = [ "proto_gen"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
sync = []
|
sync = []
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_error::{FlowyError, FlowyResult};
|
use flowy_error::{FlowyError, FlowyResult};
|
||||||
|
use flowy_http_model::revision::Revision;
|
||||||
use flowy_revision::{RevisionMergeable, RevisionObjectDeserializer, RevisionObjectSerializer};
|
use flowy_revision::{RevisionMergeable, RevisionObjectDeserializer, RevisionObjectSerializer};
|
||||||
use flowy_sync::entities::revision::Revision;
|
|
||||||
use lib_ot::core::{Extension, NodeDataBuilder, NodeOperation, NodeTree, NodeTreeContext, Selection, Transaction};
|
use lib_ot::core::{Extension, NodeDataBuilder, NodeOperation, NodeTree, NodeTreeContext, Selection, Transaction};
|
||||||
use lib_ot::text_delta::DeltaTextOperationBuilder;
|
use lib_ot::text_delta::DeltaTextOperationBuilder;
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ use crate::{DocumentEditor, DocumentUser};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_database::ConnectionPool;
|
use flowy_database::ConnectionPool;
|
||||||
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
||||||
|
use flowy_http_model::ws_data::ServerRevisionWSData;
|
||||||
use flowy_revision::{RevisionCloudService, RevisionManager};
|
use flowy_revision::{RevisionCloudService, RevisionManager};
|
||||||
use flowy_sync::entities::ws_data::ServerRevisionWSData;
|
|
||||||
use lib_infra::future::FutureResult;
|
use lib_infra::future::FutureResult;
|
||||||
use lib_ot::core::Transaction;
|
use lib_ot::core::Transaction;
|
||||||
use lib_ws::WSConnectState;
|
use lib_ws::WSConnectState;
|
||||||
|
|
|
@ -3,8 +3,8 @@ use crate::DocumentUser;
|
||||||
use async_stream::stream;
|
use async_stream::stream;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_error::FlowyError;
|
use flowy_error::FlowyError;
|
||||||
|
use flowy_http_model::revision::{RevId, Revision};
|
||||||
use flowy_revision::RevisionManager;
|
use flowy_revision::RevisionManager;
|
||||||
use flowy_sync::entities::revision::{RevId, Revision};
|
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
use lib_ot::core::Transaction;
|
use lib_ot::core::Transaction;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub mod errors {
|
||||||
pub const TEXT_BLOCK_SYNC_INTERVAL_IN_MILLIS: u64 = 1000;
|
pub const TEXT_BLOCK_SYNC_INTERVAL_IN_MILLIS: u64 = 1000;
|
||||||
|
|
||||||
use crate::errors::FlowyError;
|
use crate::errors::FlowyError;
|
||||||
use flowy_sync::entities::document::{CreateDocumentParams, DocumentIdPB, DocumentPayloadPB, ResetDocumentParams};
|
use flowy_http_model::document::{CreateDocumentParams, DocumentIdPB, DocumentPayloadPB, ResetDocumentParams};
|
||||||
use lib_infra::future::FutureResult;
|
use lib_infra::future::FutureResult;
|
||||||
|
|
||||||
pub trait DocumentCloudService: Send + Sync {
|
pub trait DocumentCloudService: Send + Sync {
|
||||||
|
|
|
@ -8,13 +8,13 @@ use bytes::Bytes;
|
||||||
|
|
||||||
use flowy_database::ConnectionPool;
|
use flowy_database::ConnectionPool;
|
||||||
use flowy_error::FlowyResult;
|
use flowy_error::FlowyResult;
|
||||||
|
use flowy_http_model::util::md5;
|
||||||
|
use flowy_http_model::{document::DocumentIdPB, revision::Revision, ws_data::ServerRevisionWSData};
|
||||||
use flowy_revision::{
|
use flowy_revision::{
|
||||||
RevisionCloudService, RevisionManager, RevisionPersistence, RevisionPersistenceConfiguration, RevisionWebSocket,
|
RevisionCloudService, RevisionManager, RevisionPersistence, RevisionPersistenceConfiguration, RevisionWebSocket,
|
||||||
SQLiteRevisionSnapshotPersistence,
|
SQLiteRevisionSnapshotPersistence,
|
||||||
};
|
};
|
||||||
use flowy_sync::client_document::initial_delta_document_content;
|
use flowy_sync::client_document::initial_delta_document_content;
|
||||||
use flowy_sync::entities::{document::DocumentIdPB, revision::Revision, ws_data::ServerRevisionWSData};
|
|
||||||
use flowy_sync::util::md5;
|
|
||||||
use lib_infra::future::FutureResult;
|
use lib_infra::future::FutureResult;
|
||||||
use lib_infra::ref_map::{RefCountHashMap, RefCountValue};
|
use lib_infra::ref_map::{RefCountHashMap, RefCountValue};
|
||||||
use lib_ws::WSConnectState;
|
use lib_ws::WSConnectState;
|
||||||
|
@ -307,7 +307,7 @@ impl RevisionCloudService for DocumentRevisionCloudService {
|
||||||
match server.fetch_document(&token, params).await? {
|
match server.fetch_document(&token, params).await? {
|
||||||
None => Err(FlowyError::record_not_found().context("Remote doesn't have this document")),
|
None => Err(FlowyError::record_not_found().context("Remote doesn't have this document")),
|
||||||
Some(payload) => {
|
Some(payload) => {
|
||||||
let bytes = Bytes::from(payload.content.clone());
|
let bytes = Bytes::from(payload.data.clone());
|
||||||
let doc_md5 = md5(&bytes);
|
let doc_md5 = md5(&bytes);
|
||||||
let revision = Revision::new(&payload.doc_id, payload.base_rev_id, payload.rev_id, bytes, doc_md5);
|
let revision = Revision::new(&payload.doc_id, payload.base_rev_id, payload.rev_id, bytes, doc_md5);
|
||||||
Ok(vec![revision])
|
Ok(vec![revision])
|
||||||
|
|
|
@ -5,16 +5,14 @@ use crate::{errors::FlowyError, DocumentEditor, DocumentUser};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_database::ConnectionPool;
|
use flowy_database::ConnectionPool;
|
||||||
use flowy_error::{internal_error, FlowyResult};
|
use flowy_error::{internal_error, FlowyResult};
|
||||||
|
use flowy_http_model::document::DocumentPayloadPB;
|
||||||
|
use flowy_http_model::revision::Revision;
|
||||||
|
use flowy_http_model::ws_data::ServerRevisionWSData;
|
||||||
use flowy_revision::{
|
use flowy_revision::{
|
||||||
RevisionCloudService, RevisionManager, RevisionMergeable, RevisionObjectDeserializer, RevisionObjectSerializer,
|
RevisionCloudService, RevisionManager, RevisionMergeable, RevisionObjectDeserializer, RevisionObjectSerializer,
|
||||||
RevisionWebSocket,
|
RevisionWebSocket,
|
||||||
};
|
};
|
||||||
use flowy_sync::entities::ws_data::ServerRevisionWSData;
|
use flowy_sync::{errors::CollaborateResult, util::make_operations_from_revisions};
|
||||||
use flowy_sync::{
|
|
||||||
entities::{document::DocumentPayloadPB, revision::Revision},
|
|
||||||
errors::CollaborateResult,
|
|
||||||
util::make_operations_from_revisions,
|
|
||||||
};
|
|
||||||
use lib_infra::future::FutureResult;
|
use lib_infra::future::FutureResult;
|
||||||
use lib_ot::core::{AttributeEntry, AttributeHashMap};
|
use lib_ot::core::{AttributeEntry, AttributeHashMap};
|
||||||
use lib_ot::{
|
use lib_ot::{
|
||||||
|
@ -47,7 +45,7 @@ impl DeltaDocumentEditor {
|
||||||
let document = rev_manager
|
let document = rev_manager
|
||||||
.initialize::<DeltaDocumentRevisionSerde>(Some(cloud_service))
|
.initialize::<DeltaDocumentRevisionSerde>(Some(cloud_service))
|
||||||
.await?;
|
.await?;
|
||||||
let operations = DeltaTextOperations::from_bytes(&document.content)?;
|
let operations = DeltaTextOperations::from_bytes(&document.data)?;
|
||||||
let rev_manager = Arc::new(rev_manager);
|
let rev_manager = Arc::new(rev_manager);
|
||||||
let doc_id = doc_id.to_string();
|
let doc_id = doc_id.to_string();
|
||||||
let user_id = user.user_id()?;
|
let user_id = user.user_id()?;
|
||||||
|
@ -255,7 +253,7 @@ impl RevisionObjectDeserializer for DeltaDocumentRevisionSerde {
|
||||||
|
|
||||||
Result::<DocumentPayloadPB, FlowyError>::Ok(DocumentPayloadPB {
|
Result::<DocumentPayloadPB, FlowyError>::Ok(DocumentPayloadPB {
|
||||||
doc_id: object_id.to_owned(),
|
doc_id: object_id.to_owned(),
|
||||||
content: delta.json_str(),
|
data: delta.json_bytes().to_vec(),
|
||||||
rev_id,
|
rev_id,
|
||||||
base_rev_id,
|
base_rev_id,
|
||||||
})
|
})
|
||||||
|
|
|
@ -3,10 +3,10 @@ use crate::DocumentUser;
|
||||||
use async_stream::stream;
|
use async_stream::stream;
|
||||||
use flowy_database::ConnectionPool;
|
use flowy_database::ConnectionPool;
|
||||||
use flowy_error::FlowyError;
|
use flowy_error::FlowyError;
|
||||||
|
use flowy_http_model::revision::{RevId, Revision};
|
||||||
use flowy_revision::{RevisionMD5, RevisionManager, TransformOperations};
|
use flowy_revision::{RevisionMD5, RevisionManager, TransformOperations};
|
||||||
use flowy_sync::{
|
use flowy_sync::{
|
||||||
client_document::{history::UndoResult, ClientDocument},
|
client_document::{history::UndoResult, ClientDocument},
|
||||||
entities::revision::{RevId, Revision},
|
|
||||||
errors::CollaborateError,
|
errors::CollaborateError,
|
||||||
};
|
};
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
|
|
|
@ -3,16 +3,13 @@ use crate::TEXT_BLOCK_SYNC_INTERVAL_IN_MILLIS;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_database::ConnectionPool;
|
use flowy_database::ConnectionPool;
|
||||||
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
||||||
use flowy_revision::*;
|
use flowy_http_model::{
|
||||||
use flowy_sync::entities::revision::Revision;
|
revision::{Revision, RevisionRange},
|
||||||
use flowy_sync::util::make_operations_from_revisions;
|
ws_data::{ClientRevisionWSData, NewDocumentUser, ServerRevisionWSDataType},
|
||||||
use flowy_sync::{
|
|
||||||
entities::{
|
|
||||||
revision::RevisionRange,
|
|
||||||
ws_data::{ClientRevisionWSData, NewDocumentUser, ServerRevisionWSDataType},
|
|
||||||
},
|
|
||||||
errors::CollaborateResult,
|
|
||||||
};
|
};
|
||||||
|
use flowy_revision::*;
|
||||||
|
use flowy_sync::errors::CollaborateResult;
|
||||||
|
use flowy_sync::util::make_operations_from_revisions;
|
||||||
use lib_infra::future::{BoxResultFuture, FutureResult};
|
use lib_infra::future::{BoxResultFuture, FutureResult};
|
||||||
use lib_ot::text_delta::DeltaTextOperations;
|
use lib_ot::text_delta::DeltaTextOperations;
|
||||||
use lib_ws::WSConnectState;
|
use lib_ws::WSConnectState;
|
||||||
|
|
|
@ -4,9 +4,10 @@ use crate::DocumentDatabase;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_database::kv::KV;
|
use flowy_database::kv::KV;
|
||||||
use flowy_error::FlowyResult;
|
use flowy_error::FlowyResult;
|
||||||
|
use flowy_http_model::revision::Revision;
|
||||||
|
use flowy_http_model::util::md5;
|
||||||
use flowy_revision::disk::{RevisionDiskCache, SyncRecord};
|
use flowy_revision::disk::{RevisionDiskCache, SyncRecord};
|
||||||
use flowy_sync::entities::revision::Revision;
|
use flowy_sync::util::make_operations_from_revisions;
|
||||||
use flowy_sync::util::{make_operations_from_revisions, md5};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
const V1_MIGRATION: &str = "DOCUMENT_V1_MIGRATION";
|
const V1_MIGRATION: &str = "DOCUMENT_V1_MIGRATION";
|
||||||
|
|
|
@ -7,11 +7,11 @@ use flowy_database::{
|
||||||
ConnectionPool,
|
ConnectionPool,
|
||||||
};
|
};
|
||||||
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
||||||
use flowy_revision::disk::{RevisionChangeset, RevisionDiskCache, RevisionState, SyncRecord};
|
use flowy_http_model::{
|
||||||
use flowy_sync::{
|
revision::{Revision, RevisionRange},
|
||||||
entities::revision::{Revision, RevisionRange},
|
|
||||||
util::md5,
|
util::md5,
|
||||||
};
|
};
|
||||||
|
use flowy_revision::disk::{RevisionChangeset, RevisionDiskCache, RevisionState, SyncRecord};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,11 @@ use flowy_database::{
|
||||||
ConnectionPool,
|
ConnectionPool,
|
||||||
};
|
};
|
||||||
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
||||||
use flowy_revision::disk::{RevisionChangeset, RevisionDiskCache, RevisionState, SyncRecord};
|
use flowy_http_model::{
|
||||||
use flowy_sync::{
|
revision::{Revision, RevisionRange},
|
||||||
entities::revision::{Revision, RevisionRange},
|
|
||||||
util::md5,
|
util::md5,
|
||||||
};
|
};
|
||||||
|
use flowy_revision::disk::{RevisionChangeset, RevisionDiskCache, RevisionState, SyncRecord};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct SQLiteDocumentRevisionPersistence {
|
pub struct SQLiteDocumentRevisionPersistence {
|
||||||
|
|
|
@ -30,4 +30,4 @@ db = ["flowy-database", "lib-sqlite", "r2d2"]
|
||||||
dart = ["flowy-error-code/dart", "lib-infra/dart"]
|
dart = ["flowy-error-code/dart", "lib-infra/dart"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen"] }
|
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["proto_gen"] }
|
|
@ -8,6 +8,7 @@ edition = "2018"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
folder-rev-model = { path = "../../../shared-lib/folder-rev-model" }
|
folder-rev-model = { path = "../../../shared-lib/folder-rev-model" }
|
||||||
flowy-sync = { path = "../../../shared-lib/flowy-sync" }
|
flowy-sync = { path = "../../../shared-lib/flowy-sync" }
|
||||||
|
flowy-http-model = { path = "../../../shared-lib/flowy-http-model" }
|
||||||
flowy-derive = { path = "../../../shared-lib/flowy-derive" }
|
flowy-derive = { path = "../../../shared-lib/flowy-derive" }
|
||||||
lib-ot = { path = "../../../shared-lib/lib-ot" }
|
lib-ot = { path = "../../../shared-lib/lib-ot" }
|
||||||
lib-infra = { path = "../../../shared-lib/lib-infra" }
|
lib-infra = { path = "../../../shared-lib/lib-infra" }
|
||||||
|
@ -41,7 +42,7 @@ flowy-folder = { path = "../flowy-folder", features = ["flowy_unit_test"]}
|
||||||
flowy-test = { path = "../flowy-test" }
|
flowy-test = { path = "../flowy-test" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen", "proto_gen"] }
|
lib-infra = { path = "../../../shared-lib/lib-infra", features = [ "proto_gen"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
|
|
@ -18,12 +18,13 @@ use flowy_revision::{
|
||||||
RevisionManager, RevisionPersistence, RevisionPersistenceConfiguration, RevisionWebSocket,
|
RevisionManager, RevisionPersistence, RevisionPersistenceConfiguration, RevisionWebSocket,
|
||||||
SQLiteRevisionSnapshotPersistence,
|
SQLiteRevisionSnapshotPersistence,
|
||||||
};
|
};
|
||||||
use flowy_sync::{client_folder::FolderPad, entities::ws_data::ServerRevisionWSData};
|
|
||||||
use folder_rev_model::user_default;
|
use folder_rev_model::user_default;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use lib_infra::future::FutureResult;
|
use lib_infra::future::FutureResult;
|
||||||
|
|
||||||
use crate::services::persistence::rev_sqlite::SQLiteFolderRevisionPersistence;
|
use crate::services::persistence::rev_sqlite::SQLiteFolderRevisionPersistence;
|
||||||
|
use flowy_http_model::ws_data::ServerRevisionWSData;
|
||||||
|
use flowy_sync::client_folder::FolderPad;
|
||||||
use std::{collections::HashMap, convert::TryInto, fmt::Formatter, sync::Arc};
|
use std::{collections::HashMap, convert::TryInto, fmt::Formatter, sync::Arc};
|
||||||
use tokio::sync::RwLock as TokioRwLock;
|
use tokio::sync::RwLock as TokioRwLock;
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
use crate::manager::FolderId;
|
use crate::manager::FolderId;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
use flowy_database::ConnectionPool;
|
||||||
use flowy_error::{FlowyError, FlowyResult};
|
use flowy_error::{FlowyError, FlowyResult};
|
||||||
|
use flowy_http_model::revision::Revision;
|
||||||
|
use flowy_http_model::ws_data::ServerRevisionWSData;
|
||||||
use flowy_revision::{
|
use flowy_revision::{
|
||||||
RevisionCloudService, RevisionManager, RevisionMergeable, RevisionObjectDeserializer, RevisionObjectSerializer,
|
RevisionCloudService, RevisionManager, RevisionMergeable, RevisionObjectDeserializer, RevisionObjectSerializer,
|
||||||
RevisionWebSocket,
|
RevisionWebSocket,
|
||||||
};
|
};
|
||||||
|
use flowy_sync::client_folder::{FolderChangeset, FolderPad};
|
||||||
use flowy_sync::util::make_operations_from_revisions;
|
use flowy_sync::util::make_operations_from_revisions;
|
||||||
use flowy_sync::{
|
|
||||||
client_folder::{FolderChangeset, FolderPad},
|
|
||||||
entities::{revision::Revision, ws_data::ServerRevisionWSData},
|
|
||||||
};
|
|
||||||
use lib_infra::future::FutureResult;
|
use lib_infra::future::FutureResult;
|
||||||
|
|
||||||
use flowy_database::ConnectionPool;
|
|
||||||
use lib_ot::core::EmptyAttributes;
|
use lib_ot::core::EmptyAttributes;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
|
@ -6,15 +6,15 @@ use crate::{
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_database::kv::KV;
|
use flowy_database::kv::KV;
|
||||||
use flowy_error::{FlowyError, FlowyResult};
|
use flowy_error::{FlowyError, FlowyResult};
|
||||||
|
use flowy_http_model::revision::Revision;
|
||||||
use flowy_revision::reset::{RevisionResettable, RevisionStructReset};
|
use flowy_revision::reset::{RevisionResettable, RevisionStructReset};
|
||||||
use flowy_sync::client_folder::make_folder_rev_json_str;
|
use flowy_sync::client_folder::make_folder_rev_json_str;
|
||||||
use flowy_sync::client_folder::FolderPad;
|
use flowy_sync::client_folder::FolderPad;
|
||||||
use flowy_sync::entities::revision::Revision;
|
|
||||||
use flowy_sync::server_folder::FolderOperationsBuilder;
|
use flowy_sync::server_folder::FolderOperationsBuilder;
|
||||||
use folder_rev_model::{AppRevision, FolderRevision, ViewRevision, WorkspaceRevision};
|
use folder_rev_model::{AppRevision, FolderRevision, ViewRevision, WorkspaceRevision};
|
||||||
|
|
||||||
use crate::services::persistence::rev_sqlite::SQLiteFolderRevisionPersistence;
|
use crate::services::persistence::rev_sqlite::SQLiteFolderRevisionPersistence;
|
||||||
use flowy_sync::util::md5;
|
use flowy_http_model::util::md5;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
const V1_MIGRATION: &str = "FOLDER_V1_MIGRATION";
|
const V1_MIGRATION: &str = "FOLDER_V1_MIGRATION";
|
||||||
|
|
|
@ -10,8 +10,9 @@ use crate::{
|
||||||
};
|
};
|
||||||
use flowy_database::ConnectionPool;
|
use flowy_database::ConnectionPool;
|
||||||
use flowy_error::{FlowyError, FlowyResult};
|
use flowy_error::{FlowyError, FlowyResult};
|
||||||
|
use flowy_http_model::revision::Revision;
|
||||||
use flowy_revision::disk::{RevisionDiskCache, RevisionState, SyncRecord};
|
use flowy_revision::disk::{RevisionDiskCache, RevisionState, SyncRecord};
|
||||||
use flowy_sync::{client_folder::FolderPad, entities::revision::Revision};
|
use flowy_sync::client_folder::FolderPad;
|
||||||
use folder_rev_model::{AppRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
use folder_rev_model::{AppRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
||||||
|
|
||||||
use crate::services::persistence::rev_sqlite::SQLiteFolderRevisionPersistence;
|
use crate::services::persistence::rev_sqlite::SQLiteFolderRevisionPersistence;
|
||||||
|
|
|
@ -7,12 +7,9 @@ use flowy_database::{
|
||||||
ConnectionPool,
|
ConnectionPool,
|
||||||
};
|
};
|
||||||
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
||||||
|
use flowy_http_model::revision::{Revision, RevisionRange};
|
||||||
|
use flowy_http_model::util::md5;
|
||||||
use flowy_revision::disk::{RevisionChangeset, RevisionDiskCache, RevisionState, SyncRecord};
|
use flowy_revision::disk::{RevisionChangeset, RevisionDiskCache, RevisionState, SyncRecord};
|
||||||
use flowy_sync::{
|
|
||||||
entities::revision::{Revision, RevisionRange},
|
|
||||||
util::md5,
|
|
||||||
};
|
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct SQLiteFolderRevisionPersistence {
|
pub struct SQLiteFolderRevisionPersistence {
|
||||||
|
|
|
@ -16,7 +16,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_database::kv::KV;
|
use flowy_database::kv::KV;
|
||||||
use flowy_sync::entities::document::DocumentIdPB;
|
use flowy_http_model::document::DocumentIdPB;
|
||||||
use folder_rev_model::{gen_view_id, ViewRevision};
|
use folder_rev_model::{gen_view_id, ViewRevision};
|
||||||
use futures::{FutureExt, StreamExt};
|
use futures::{FutureExt, StreamExt};
|
||||||
use std::{collections::HashSet, sync::Arc};
|
use std::{collections::HashSet, sync::Arc};
|
||||||
|
|
|
@ -2,17 +2,12 @@ use crate::services::FOLDER_SYNC_INTERVAL_IN_MILLIS;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_database::ConnectionPool;
|
use flowy_database::ConnectionPool;
|
||||||
use flowy_error::{FlowyError, FlowyResult};
|
use flowy_error::{FlowyError, FlowyResult};
|
||||||
|
use flowy_http_model::revision::{Revision, RevisionRange};
|
||||||
|
use flowy_http_model::ws_data::{ClientRevisionWSData, NewDocumentUser, ServerRevisionWSDataType};
|
||||||
use flowy_revision::*;
|
use flowy_revision::*;
|
||||||
use flowy_sync::entities::revision::Revision;
|
use flowy_sync::client_folder::FolderPad;
|
||||||
use flowy_sync::server_folder::FolderOperations;
|
use flowy_sync::server_folder::FolderOperations;
|
||||||
use flowy_sync::util::make_operations_from_revisions;
|
use flowy_sync::util::make_operations_from_revisions;
|
||||||
use flowy_sync::{
|
|
||||||
client_folder::FolderPad,
|
|
||||||
entities::{
|
|
||||||
revision::RevisionRange,
|
|
||||||
ws_data::{ClientRevisionWSData, NewDocumentUser, ServerRevisionWSDataType},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
use lib_infra::future::{BoxResultFuture, FutureResult};
|
use lib_infra::future::{BoxResultFuture, FutureResult};
|
||||||
use lib_ot::core::OperationTransform;
|
use lib_ot::core::OperationTransform;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
|
|
|
@ -16,9 +16,9 @@ use flowy_folder::entities::{
|
||||||
use flowy_folder::event_map::FolderEvent::*;
|
use flowy_folder::event_map::FolderEvent::*;
|
||||||
use flowy_folder::{errors::ErrorCode, services::folder_editor::FolderEditor};
|
use flowy_folder::{errors::ErrorCode, services::folder_editor::FolderEditor};
|
||||||
|
|
||||||
|
use flowy_http_model::document::DocumentPayloadPB;
|
||||||
use flowy_revision::disk::RevisionState;
|
use flowy_revision::disk::RevisionState;
|
||||||
use flowy_revision::REVISION_WRITE_INTERVAL_IN_MILLIS;
|
use flowy_revision::REVISION_WRITE_INTERVAL_IN_MILLIS;
|
||||||
use flowy_sync::entities::document::DocumentPayloadPB;
|
|
||||||
use flowy_test::{event_builder::*, FlowySDKTest};
|
use flowy_test::{event_builder::*, FlowySDKTest};
|
||||||
use std::{sync::Arc, time::Duration};
|
use std::{sync::Arc, time::Duration};
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
|
|
|
@ -15,6 +15,7 @@ lib-ot = { path = "../../../shared-lib/lib-ot" }
|
||||||
lib-infra = { path = "../../../shared-lib/lib-infra" }
|
lib-infra = { path = "../../../shared-lib/lib-infra" }
|
||||||
grid-rev-model = { path = "../../../shared-lib/grid-rev-model" }
|
grid-rev-model = { path = "../../../shared-lib/grid-rev-model" }
|
||||||
flowy-sync = { path = "../../../shared-lib/flowy-sync" }
|
flowy-sync = { path = "../../../shared-lib/flowy-sync" }
|
||||||
|
flowy-http-model = { path = "../../../shared-lib/flowy-http-model" }
|
||||||
flowy-database = { path = "../flowy-database" }
|
flowy-database = { path = "../flowy-database" }
|
||||||
|
|
||||||
strum = "0.21"
|
strum = "0.21"
|
||||||
|
@ -47,7 +48,7 @@ flowy-test = { path = "../flowy-test" }
|
||||||
flowy-grid = { path = "../flowy-grid", features = ["flowy_unit_test"]}
|
flowy-grid = { path = "../flowy-grid", features = ["flowy_unit_test"]}
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen", "proto_gen"] }
|
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["proto_gen"] }
|
||||||
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
|
@ -12,12 +12,12 @@ use bytes::Bytes;
|
||||||
|
|
||||||
use flowy_database::ConnectionPool;
|
use flowy_database::ConnectionPool;
|
||||||
use flowy_error::{FlowyError, FlowyResult};
|
use flowy_error::{FlowyError, FlowyResult};
|
||||||
|
use flowy_http_model::revision::Revision;
|
||||||
use flowy_revision::{
|
use flowy_revision::{
|
||||||
RevisionManager, RevisionPersistence, RevisionPersistenceConfiguration, RevisionWebSocket,
|
RevisionManager, RevisionPersistence, RevisionPersistenceConfiguration, RevisionWebSocket,
|
||||||
SQLiteRevisionSnapshotPersistence,
|
SQLiteRevisionSnapshotPersistence,
|
||||||
};
|
};
|
||||||
use flowy_sync::client_grid::{make_grid_block_operations, make_grid_operations, make_grid_view_operations};
|
use flowy_sync::client_grid::{make_grid_block_operations, make_grid_operations, make_grid_view_operations};
|
||||||
use flowy_sync::entities::revision::Revision;
|
|
||||||
use grid_rev_model::{BuildGridContext, GridRevision, GridViewRevision};
|
use grid_rev_model::{BuildGridContext, GridRevision, GridViewRevision};
|
||||||
use lib_infra::ref_map::{RefCountHashMap, RefCountValue};
|
use lib_infra::ref_map::{RefCountHashMap, RefCountValue};
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use crate::entities::RowPB;
|
use crate::entities::RowPB;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_error::{FlowyError, FlowyResult};
|
use flowy_error::{FlowyError, FlowyResult};
|
||||||
|
use flowy_http_model::revision::Revision;
|
||||||
use flowy_revision::{
|
use flowy_revision::{
|
||||||
RevisionCloudService, RevisionManager, RevisionMergeable, RevisionObjectDeserializer, RevisionObjectSerializer,
|
RevisionCloudService, RevisionManager, RevisionMergeable, RevisionObjectDeserializer, RevisionObjectSerializer,
|
||||||
};
|
};
|
||||||
use flowy_sync::client_grid::{GridBlockRevisionChangeset, GridBlockRevisionPad};
|
use flowy_sync::client_grid::{GridBlockRevisionChangeset, GridBlockRevisionPad};
|
||||||
use flowy_sync::entities::revision::Revision;
|
|
||||||
use flowy_sync::util::make_operations_from_revisions;
|
use flowy_sync::util::make_operations_from_revisions;
|
||||||
use grid_rev_model::{CellRevision, GridBlockRevision, RowChangeset, RowRevision};
|
use grid_rev_model::{CellRevision, GridBlockRevision, RowChangeset, RowRevision};
|
||||||
use lib_infra::future::FutureResult;
|
use lib_infra::future::FutureResult;
|
||||||
|
|
|
@ -15,11 +15,11 @@ use crate::services::persistence::block_index::BlockIndexCache;
|
||||||
use crate::services::row::{make_grid_blocks, make_rows_from_row_revs, GridBlockSnapshot, RowRevisionBuilder};
|
use crate::services::row::{make_grid_blocks, make_rows_from_row_revs, GridBlockSnapshot, RowRevisionBuilder};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_error::{ErrorCode, FlowyError, FlowyResult};
|
use flowy_error::{ErrorCode, FlowyError, FlowyResult};
|
||||||
|
use flowy_http_model::revision::Revision;
|
||||||
use flowy_revision::{
|
use flowy_revision::{
|
||||||
RevisionCloudService, RevisionManager, RevisionMergeable, RevisionObjectDeserializer, RevisionObjectSerializer,
|
RevisionCloudService, RevisionManager, RevisionMergeable, RevisionObjectDeserializer, RevisionObjectSerializer,
|
||||||
};
|
};
|
||||||
use flowy_sync::client_grid::{GridRevisionChangeset, GridRevisionPad, JsonDeserializer};
|
use flowy_sync::client_grid::{GridRevisionChangeset, GridRevisionPad, JsonDeserializer};
|
||||||
use flowy_sync::entities::revision::Revision;
|
|
||||||
use flowy_sync::errors::{CollaborateError, CollaborateResult};
|
use flowy_sync::errors::{CollaborateError, CollaborateResult};
|
||||||
use flowy_sync::util::make_operations_from_revisions;
|
use flowy_sync::util::make_operations_from_revisions;
|
||||||
use grid_rev_model::*;
|
use grid_rev_model::*;
|
||||||
|
|
|
@ -14,11 +14,11 @@ use crate::services::group::{
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_database::ConnectionPool;
|
use flowy_database::ConnectionPool;
|
||||||
use flowy_error::{FlowyError, FlowyResult};
|
use flowy_error::{FlowyError, FlowyResult};
|
||||||
|
use flowy_http_model::revision::Revision;
|
||||||
use flowy_revision::{
|
use flowy_revision::{
|
||||||
RevisionCloudService, RevisionManager, RevisionMergeable, RevisionObjectDeserializer, RevisionObjectSerializer,
|
RevisionCloudService, RevisionManager, RevisionMergeable, RevisionObjectDeserializer, RevisionObjectSerializer,
|
||||||
};
|
};
|
||||||
use flowy_sync::client_grid::{GridViewRevisionChangeset, GridViewRevisionPad};
|
use flowy_sync::client_grid::{GridViewRevisionChangeset, GridViewRevisionPad};
|
||||||
use flowy_sync::entities::revision::Revision;
|
|
||||||
use flowy_sync::util::make_operations_from_revisions;
|
use flowy_sync::util::make_operations_from_revisions;
|
||||||
use grid_rev_model::{
|
use grid_rev_model::{
|
||||||
gen_grid_filter_id, FieldRevision, FieldTypeRevision, FilterConfigurationRevision, GroupConfigurationRevision,
|
gen_grid_filter_id, FieldRevision, FieldTypeRevision, FilterConfigurationRevision, GroupConfigurationRevision,
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
use crate::manager::GridUser;
|
use crate::manager::GridUser;
|
||||||
|
use crate::services::persistence::rev_sqlite::SQLiteGridRevisionPersistence;
|
||||||
use crate::services::persistence::GridDatabase;
|
use crate::services::persistence::GridDatabase;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_database::kv::KV;
|
use flowy_database::kv::KV;
|
||||||
use flowy_error::FlowyResult;
|
use flowy_error::FlowyResult;
|
||||||
|
use flowy_http_model::revision::Revision;
|
||||||
|
use flowy_http_model::util::md5;
|
||||||
use flowy_revision::reset::{RevisionResettable, RevisionStructReset};
|
use flowy_revision::reset::{RevisionResettable, RevisionStructReset};
|
||||||
use flowy_sync::client_grid::{make_grid_rev_json_str, GridOperationsBuilder, GridRevisionPad};
|
use flowy_sync::client_grid::{make_grid_rev_json_str, GridOperationsBuilder, GridRevisionPad};
|
||||||
use flowy_sync::entities::revision::Revision;
|
|
||||||
use flowy_sync::util::md5;
|
|
||||||
use grid_rev_model::GridRevision;
|
use grid_rev_model::GridRevision;
|
||||||
|
|
||||||
use crate::services::persistence::rev_sqlite::SQLiteGridRevisionPersistence;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
const V1_MIGRATION: &str = "GRID_V1_MIGRATION";
|
const V1_MIGRATION: &str = "GRID_V1_MIGRATION";
|
||||||
|
|
|
@ -7,11 +7,9 @@ use flowy_database::{
|
||||||
ConnectionPool,
|
ConnectionPool,
|
||||||
};
|
};
|
||||||
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
||||||
|
use flowy_http_model::revision::{Revision, RevisionRange};
|
||||||
|
use flowy_http_model::util::md5;
|
||||||
use flowy_revision::disk::{RevisionChangeset, RevisionDiskCache, RevisionState, SyncRecord};
|
use flowy_revision::disk::{RevisionChangeset, RevisionDiskCache, RevisionState, SyncRecord};
|
||||||
use flowy_sync::{
|
|
||||||
entities::revision::{Revision, RevisionRange},
|
|
||||||
util::md5,
|
|
||||||
};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct SQLiteGridBlockRevisionPersistence {
|
pub struct SQLiteGridBlockRevisionPersistence {
|
||||||
|
|
|
@ -7,11 +7,9 @@ use flowy_database::{
|
||||||
ConnectionPool,
|
ConnectionPool,
|
||||||
};
|
};
|
||||||
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
||||||
|
use flowy_http_model::revision::{Revision, RevisionRange};
|
||||||
|
use flowy_http_model::util::md5;
|
||||||
use flowy_revision::disk::{RevisionChangeset, RevisionDiskCache, RevisionState, SyncRecord};
|
use flowy_revision::disk::{RevisionChangeset, RevisionDiskCache, RevisionState, SyncRecord};
|
||||||
use flowy_sync::{
|
|
||||||
entities::revision::{Revision, RevisionRange},
|
|
||||||
util::md5,
|
|
||||||
};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct SQLiteGridRevisionPersistence {
|
pub struct SQLiteGridRevisionPersistence {
|
||||||
|
|
|
@ -7,11 +7,9 @@ use flowy_database::{
|
||||||
ConnectionPool,
|
ConnectionPool,
|
||||||
};
|
};
|
||||||
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
||||||
|
use flowy_http_model::revision::{Revision, RevisionRange};
|
||||||
|
use flowy_http_model::util::md5;
|
||||||
use flowy_revision::disk::{RevisionChangeset, RevisionDiskCache, RevisionState, SyncRecord};
|
use flowy_revision::disk::{RevisionChangeset, RevisionDiskCache, RevisionState, SyncRecord};
|
||||||
use flowy_sync::{
|
|
||||||
entities::revision::{Revision, RevisionRange},
|
|
||||||
util::md5,
|
|
||||||
};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct SQLiteGridViewRevisionPersistence {
|
pub struct SQLiteGridViewRevisionPersistence {
|
||||||
|
|
|
@ -10,6 +10,7 @@ lib-dispatch = { path = "../lib-dispatch" }
|
||||||
flowy-error = { path = "../flowy-error", features = ["collaboration", "http_server"] }
|
flowy-error = { path = "../flowy-error", features = ["collaboration", "http_server"] }
|
||||||
flowy-derive = { path = "../../../shared-lib/flowy-derive" }
|
flowy-derive = { path = "../../../shared-lib/flowy-derive" }
|
||||||
flowy-sync = { path = "../../../shared-lib/flowy-sync"}
|
flowy-sync = { path = "../../../shared-lib/flowy-sync"}
|
||||||
|
flowy-http-model = { path = "../../../shared-lib/flowy-http-model"}
|
||||||
folder-rev-model = { path = "../../../shared-lib/folder-rev-model"}
|
folder-rev-model = { path = "../../../shared-lib/folder-rev-model"}
|
||||||
flowy-folder = { path = "../flowy-folder" }
|
flowy-folder = { path = "../flowy-folder" }
|
||||||
flowy-user = { path = "../flowy-user" }
|
flowy-user = { path = "../flowy-user" }
|
||||||
|
@ -43,9 +44,8 @@ http_server = []
|
||||||
dart = [
|
dart = [
|
||||||
"lib-infra/dart",
|
"lib-infra/dart",
|
||||||
"flowy-user/dart",
|
"flowy-user/dart",
|
||||||
"flowy-sync/dart",
|
|
||||||
"flowy-error/dart",
|
"flowy-error/dart",
|
||||||
]
|
]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen"] }
|
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["proto_gen"] }
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use flowy_document::DocumentCloudService;
|
use flowy_document::DocumentCloudService;
|
||||||
use flowy_error::FlowyError;
|
use flowy_error::FlowyError;
|
||||||
use flowy_sync::entities::document::{CreateDocumentParams, DocumentIdPB, DocumentPayloadPB, ResetDocumentParams};
|
use flowy_http_model::document::{CreateDocumentParams, DocumentIdPB, DocumentPayloadPB, ResetDocumentParams};
|
||||||
use http_flowy::response::FlowyResponse;
|
use http_flowy::response::FlowyResponse;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use lib_infra::future::FutureResult;
|
use lib_infra::future::FutureResult;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use flowy_sync::entities::revision::{RepeatedRevision, Revision};
|
use flowy_http_model::document::DocumentPayloadPB;
|
||||||
|
use flowy_http_model::folder::FolderInfo;
|
||||||
|
use flowy_http_model::revision::{RepeatedRevision, Revision};
|
||||||
use flowy_sync::{
|
use flowy_sync::{
|
||||||
entities::{document::DocumentPayloadPB, folder::FolderInfo},
|
|
||||||
errors::CollaborateError,
|
errors::CollaborateError,
|
||||||
server_document::*,
|
server_document::*,
|
||||||
server_folder::FolderCloudPersistence,
|
server_folder::FolderCloudPersistence,
|
||||||
|
|
|
@ -4,12 +4,7 @@ use bytes::Bytes;
|
||||||
use flowy_error::{internal_error, FlowyError};
|
use flowy_error::{internal_error, FlowyError};
|
||||||
use flowy_folder::event_map::FolderCouldServiceV1;
|
use flowy_folder::event_map::FolderCouldServiceV1;
|
||||||
use flowy_sync::{
|
use flowy_sync::{
|
||||||
entities::{
|
|
||||||
document::{CreateDocumentParams, DocumentIdPB, DocumentPayloadPB, ResetDocumentParams},
|
|
||||||
ws_data::{ClientRevisionWSData, ClientRevisionWSDataType},
|
|
||||||
},
|
|
||||||
errors::CollaborateError,
|
errors::CollaborateError,
|
||||||
protobuf::ClientRevisionWSData as ClientRevisionWSDataPB,
|
|
||||||
server_document::ServerDocumentManager,
|
server_document::ServerDocumentManager,
|
||||||
server_folder::ServerFolderManager,
|
server_folder::ServerFolderManager,
|
||||||
synchronizer::{RevisionSyncResponse, RevisionUser},
|
synchronizer::{RevisionSyncResponse, RevisionUser},
|
||||||
|
@ -258,6 +253,9 @@ use flowy_folder::entities::{
|
||||||
view::{CreateViewParams, RepeatedViewIdPB, UpdateViewParams, ViewIdPB},
|
view::{CreateViewParams, RepeatedViewIdPB, UpdateViewParams, ViewIdPB},
|
||||||
workspace::{CreateWorkspaceParams, UpdateWorkspaceParams, WorkspaceIdPB},
|
workspace::{CreateWorkspaceParams, UpdateWorkspaceParams, WorkspaceIdPB},
|
||||||
};
|
};
|
||||||
|
use flowy_http_model::document::{CreateDocumentParams, DocumentIdPB, DocumentPayloadPB, ResetDocumentParams};
|
||||||
|
use flowy_http_model::protobuf::ClientRevisionWSData as ClientRevisionWSDataPB;
|
||||||
|
use flowy_http_model::ws_data::{ClientRevisionWSData, ClientRevisionWSDataType};
|
||||||
use flowy_user::entities::{
|
use flowy_user::entities::{
|
||||||
SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserProfileParams, UserProfilePB,
|
SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserProfileParams, UserProfilePB,
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
flowy-sync = { path = "../../../shared-lib/flowy-sync" }
|
flowy-http-model = { path = "../../../shared-lib/flowy-http-model" }
|
||||||
lib-ws = { path = "../../../shared-lib/lib-ws" }
|
lib-ws = { path = "../../../shared-lib/lib-ws" }
|
||||||
lib-infra = { path = "../../../shared-lib/lib-infra" }
|
lib-infra = { path = "../../../shared-lib/lib-infra" }
|
||||||
flowy-error = { path = "../flowy-error" }
|
flowy-error = { path = "../flowy-error" }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use flowy_error::{FlowyError, FlowyResult};
|
use flowy_error::{FlowyError, FlowyResult};
|
||||||
use flowy_sync::entities::revision::{RevId, Revision, RevisionRange};
|
use flowy_http_model::revision::{RevId, Revision, RevisionRange};
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::disk::SyncRecord;
|
||||||
use crate::REVISION_WRITE_INTERVAL_IN_MILLIS;
|
use crate::REVISION_WRITE_INTERVAL_IN_MILLIS;
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use flowy_error::{FlowyError, FlowyResult};
|
use flowy_error::{FlowyError, FlowyResult};
|
||||||
use flowy_sync::entities::revision::RevisionRange;
|
use flowy_http_model::revision::RevisionRange;
|
||||||
use std::{borrow::Cow, sync::Arc, time::Duration};
|
use std::{borrow::Cow, sync::Arc, time::Duration};
|
||||||
use tokio::{sync::RwLock, task::JoinHandle};
|
use tokio::{sync::RwLock, task::JoinHandle};
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::disk::{RevisionDiskCache, SyncRecord};
|
||||||
use crate::{RevisionLoader, RevisionPersistence, RevisionPersistenceConfiguration};
|
use crate::{RevisionLoader, RevisionPersistence, RevisionPersistenceConfiguration};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_error::{FlowyError, FlowyResult};
|
use flowy_error::{FlowyError, FlowyResult};
|
||||||
use flowy_sync::entities::revision::Revision;
|
use flowy_http_model::revision::Revision;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{RevisionMD5, RevisionManager};
|
use crate::{RevisionMD5, RevisionManager};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_error::{FlowyError, FlowyResult};
|
use flowy_error::{FlowyError, FlowyResult};
|
||||||
use flowy_sync::entities::{
|
use flowy_http_model::{
|
||||||
revision::{RepeatedRevision, Revision, RevisionRange},
|
revision::{RepeatedRevision, Revision, RevisionRange},
|
||||||
ws_data::ServerRevisionWSDataType,
|
ws_data::ServerRevisionWSDataType,
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@ use flowy_database::{
|
||||||
ConnectionPool,
|
ConnectionPool,
|
||||||
};
|
};
|
||||||
use flowy_error::{internal_error, FlowyResult};
|
use flowy_error::{internal_error, FlowyResult};
|
||||||
use flowy_sync::entities::revision::Revision;
|
use flowy_http_model::revision::Revision;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub struct SQLiteRevisionHistoryPersistence {
|
pub struct SQLiteRevisionHistoryPersistence {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::{RevisionCompactor, RevisionHistory};
|
||||||
use async_stream::stream;
|
use async_stream::stream;
|
||||||
|
|
||||||
use flowy_error::{FlowyError, FlowyResult};
|
use flowy_error::{FlowyError, FlowyResult};
|
||||||
use flowy_sync::entities::revision::Revision;
|
use flowy_http_model::revision::Revision;
|
||||||
use futures_util::future::BoxFuture;
|
use futures_util::future::BoxFuture;
|
||||||
use futures_util::stream::StreamExt;
|
use futures_util::stream::StreamExt;
|
||||||
use futures_util::FutureExt;
|
use futures_util::FutureExt;
|
||||||
|
|
|
@ -2,11 +2,11 @@ use crate::disk::RevisionState;
|
||||||
use crate::{RevisionPersistence, RevisionSnapshotDiskCache, RevisionSnapshotManager, WSDataProviderDataSource};
|
use crate::{RevisionPersistence, RevisionSnapshotDiskCache, RevisionSnapshotManager, WSDataProviderDataSource};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_error::{FlowyError, FlowyResult};
|
use flowy_error::{FlowyError, FlowyResult};
|
||||||
use flowy_sync::{
|
use flowy_http_model::revision::{Revision, RevisionRange};
|
||||||
entities::revision::{Revision, RevisionRange},
|
use flowy_http_model::util::md5;
|
||||||
util::{md5, pair_rev_id_from_revisions, RevIdCounter},
|
|
||||||
};
|
|
||||||
use lib_infra::future::FutureResult;
|
use lib_infra::future::FutureResult;
|
||||||
|
use std::sync::atomic::AtomicI64;
|
||||||
|
use std::sync::atomic::Ordering::SeqCst;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub trait RevisionCloudService: Send + Sync {
|
pub trait RevisionCloudService: Send + Sync {
|
||||||
|
@ -349,3 +349,39 @@ impl PartialEq<Self> for RevisionMD5 {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::cmp::Eq for RevisionMD5 {}
|
impl std::cmp::Eq for RevisionMD5 {}
|
||||||
|
|
||||||
|
fn pair_rev_id_from_revisions(revisions: &[Revision]) -> (i64, i64) {
|
||||||
|
let mut rev_id = 0;
|
||||||
|
revisions.iter().for_each(|revision| {
|
||||||
|
if rev_id < revision.rev_id {
|
||||||
|
rev_id = revision.rev_id;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if rev_id > 0 {
|
||||||
|
(rev_id - 1, rev_id)
|
||||||
|
} else {
|
||||||
|
(0, rev_id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct RevIdCounter(pub AtomicI64);
|
||||||
|
|
||||||
|
impl RevIdCounter {
|
||||||
|
pub fn new(n: i64) -> Self {
|
||||||
|
Self(AtomicI64::new(n))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn next_id(&self) -> i64 {
|
||||||
|
let _ = self.0.fetch_add(1, SeqCst);
|
||||||
|
self.value()
|
||||||
|
}
|
||||||
|
pub fn value(&self) -> i64 {
|
||||||
|
self.0.load(SeqCst)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set(&self, n: i64) {
|
||||||
|
let _ = self.0.fetch_update(SeqCst, SeqCst, |_| Some(n));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::disk::{RevisionState, SyncRecord};
|
||||||
use crate::memory::RevisionMemoryCache;
|
use crate::memory::RevisionMemoryCache;
|
||||||
use crate::RevisionMergeable;
|
use crate::RevisionMergeable;
|
||||||
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
use flowy_error::{internal_error, FlowyError, FlowyResult};
|
||||||
use flowy_sync::entities::revision::{Revision, RevisionRange};
|
use flowy_http_model::revision::{Revision, RevisionRange};
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::{borrow::Cow, sync::Arc};
|
use std::{borrow::Cow, sync::Arc};
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::ConflictRevisionSink;
|
||||||
use async_stream::stream;
|
use async_stream::stream;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_error::{FlowyError, FlowyResult};
|
use flowy_error::{FlowyError, FlowyResult};
|
||||||
use flowy_sync::entities::{
|
use flowy_http_model::{
|
||||||
revision::{RevId, Revision, RevisionRange},
|
revision::{RevId, Revision, RevisionRange},
|
||||||
ws_data::{ClientRevisionWSData, NewDocumentUser, ServerRevisionWSData, ServerRevisionWSDataType},
|
ws_data::{ClientRevisionWSData, NewDocumentUser, ServerRevisionWSData, ServerRevisionWSDataType},
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,8 +7,8 @@ use flowy_revision::{
|
||||||
REVISION_WRITE_INTERVAL_IN_MILLIS,
|
REVISION_WRITE_INTERVAL_IN_MILLIS,
|
||||||
};
|
};
|
||||||
|
|
||||||
use flowy_sync::entities::revision::{Revision, RevisionRange};
|
use flowy_http_model::revision::{Revision, RevisionRange};
|
||||||
use flowy_sync::util::md5;
|
use flowy_http_model::util::md5;
|
||||||
use nanoid::nanoid;
|
use nanoid::nanoid;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
|
@ -18,25 +18,15 @@ flowy-document = { path = "../flowy-document", default-features = false }
|
||||||
flowy-revision = { path = "../flowy-revision" }
|
flowy-revision = { path = "../flowy-revision" }
|
||||||
|
|
||||||
tracing = { version = "0.1" }
|
tracing = { version = "0.1" }
|
||||||
log = "0.4.14"
|
|
||||||
futures-core = { version = "0.3", default-features = false }
|
futures-core = { version = "0.3", default-features = false }
|
||||||
color-eyre = { version = "0.5", default-features = false }
|
|
||||||
bytes = "1.0"
|
bytes = "1.0"
|
||||||
tokio = { version = "1", features = ["rt"] }
|
tokio = { version = "1", features = ["rt"] }
|
||||||
parking_lot = "0.12.1"
|
parking_lot = "0.12.1"
|
||||||
|
|
||||||
flowy-sync = { path = "../../../shared-lib/flowy-sync" }
|
flowy-http-model = { path = "../../../shared-lib/flowy-http-model" }
|
||||||
lib-ws = { path = "../../../shared-lib/lib-ws" }
|
lib-ws = { path = "../../../shared-lib/lib-ws" }
|
||||||
lib-infra = { path = "../../../shared-lib/lib-infra" }
|
lib-infra = { path = "../../../shared-lib/lib-infra" }
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
|
||||||
bincode = { version = "1.3" }
|
|
||||||
protobuf = { version = "2.24.1" }
|
|
||||||
claim = "0.5.0"
|
|
||||||
tokio = { version = "1", features = ["full"] }
|
|
||||||
futures-util = "0.3.15"
|
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
http_sync = ["flowy-folder/cloud_sync", "flowy-document/cloud_sync"]
|
http_sync = ["flowy-folder/cloud_sync", "flowy-document/cloud_sync"]
|
||||||
native_sync = ["flowy-folder/cloud_sync", "flowy-document/cloud_sync"]
|
native_sync = ["flowy-folder/cloud_sync", "flowy-document/cloud_sync"]
|
||||||
|
@ -45,7 +35,6 @@ dart = [
|
||||||
"flowy-user/dart",
|
"flowy-user/dart",
|
||||||
"flowy-net/dart",
|
"flowy-net/dart",
|
||||||
"flowy-folder/dart",
|
"flowy-folder/dart",
|
||||||
"flowy-sync/dart",
|
|
||||||
"flowy-grid/dart",
|
"flowy-grid/dart",
|
||||||
"flowy-document/dart",
|
"flowy-document/dart",
|
||||||
]
|
]
|
||||||
|
|
|
@ -4,12 +4,12 @@ use flowy_document::{
|
||||||
errors::{internal_error, FlowyError},
|
errors::{internal_error, FlowyError},
|
||||||
DocumentCloudService, DocumentConfig, DocumentDatabase, DocumentManager, DocumentUser,
|
DocumentCloudService, DocumentConfig, DocumentDatabase, DocumentManager, DocumentUser,
|
||||||
};
|
};
|
||||||
|
use flowy_http_model::ws_data::ClientRevisionWSData;
|
||||||
use flowy_net::ClientServerConfiguration;
|
use flowy_net::ClientServerConfiguration;
|
||||||
use flowy_net::{
|
use flowy_net::{
|
||||||
http_server::document::DocumentCloudServiceImpl, local_server::LocalServer, ws::connection::FlowyWebSocketConnect,
|
http_server::document::DocumentCloudServiceImpl, local_server::LocalServer, ws::connection::FlowyWebSocketConnect,
|
||||||
};
|
};
|
||||||
use flowy_revision::{RevisionWebSocket, WSStateReceiver};
|
use flowy_revision::{RevisionWebSocket, WSStateReceiver};
|
||||||
use flowy_sync::entities::ws_data::ClientRevisionWSData;
|
|
||||||
use flowy_user::services::UserSession;
|
use flowy_user::services::UserSession;
|
||||||
use futures_core::future::BoxFuture;
|
use futures_core::future::BoxFuture;
|
||||||
use lib_infra::future::BoxResultFuture;
|
use lib_infra::future::BoxResultFuture;
|
||||||
|
|
|
@ -12,13 +12,13 @@ use flowy_folder::{
|
||||||
use flowy_grid::entities::GridLayout;
|
use flowy_grid::entities::GridLayout;
|
||||||
use flowy_grid::manager::{make_grid_view_data, GridManager};
|
use flowy_grid::manager::{make_grid_view_data, GridManager};
|
||||||
use flowy_grid::util::{make_default_board, make_default_grid};
|
use flowy_grid::util::{make_default_board, make_default_grid};
|
||||||
|
use flowy_http_model::revision::Revision;
|
||||||
|
use flowy_http_model::ws_data::ClientRevisionWSData;
|
||||||
use flowy_net::ClientServerConfiguration;
|
use flowy_net::ClientServerConfiguration;
|
||||||
use flowy_net::{
|
use flowy_net::{
|
||||||
http_server::folder::FolderHttpCloudService, local_server::LocalServer, ws::connection::FlowyWebSocketConnect,
|
http_server::folder::FolderHttpCloudService, local_server::LocalServer, ws::connection::FlowyWebSocketConnect,
|
||||||
};
|
};
|
||||||
use flowy_revision::{RevisionWebSocket, WSStateReceiver};
|
use flowy_revision::{RevisionWebSocket, WSStateReceiver};
|
||||||
use flowy_sync::entities::revision::Revision;
|
|
||||||
use flowy_sync::entities::ws_data::ClientRevisionWSData;
|
|
||||||
use flowy_user::services::UserSession;
|
use flowy_user::services::UserSession;
|
||||||
use futures_core::future::BoxFuture;
|
use futures_core::future::BoxFuture;
|
||||||
use grid_rev_model::BuildGridContext;
|
use grid_rev_model::BuildGridContext;
|
||||||
|
|
|
@ -3,9 +3,9 @@ use bytes::Bytes;
|
||||||
use flowy_database::ConnectionPool;
|
use flowy_database::ConnectionPool;
|
||||||
use flowy_grid::manager::{GridManager, GridUser};
|
use flowy_grid::manager::{GridManager, GridUser};
|
||||||
use flowy_grid::services::persistence::GridDatabase;
|
use flowy_grid::services::persistence::GridDatabase;
|
||||||
|
use flowy_http_model::ws_data::ClientRevisionWSData;
|
||||||
use flowy_net::ws::connection::FlowyWebSocketConnect;
|
use flowy_net::ws::connection::FlowyWebSocketConnect;
|
||||||
use flowy_revision::{RevisionWebSocket, WSStateReceiver};
|
use flowy_revision::{RevisionWebSocket, WSStateReceiver};
|
||||||
use flowy_sync::entities::ws_data::ClientRevisionWSData;
|
|
||||||
use flowy_user::services::UserSession;
|
use flowy_user::services::UserSession;
|
||||||
use futures_core::future::BoxFuture;
|
use futures_core::future::BoxFuture;
|
||||||
use lib_infra::future::BoxResultFuture;
|
use lib_infra::future::BoxResultFuture;
|
||||||
|
|
|
@ -295,7 +295,7 @@ async fn _listen_user_status(
|
||||||
|
|
||||||
match result().await {
|
match result().await {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(e) => log::error!("{}", e),
|
Err(e) => tracing::error!("{}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,4 +48,4 @@ rand = "0.8.5"
|
||||||
dart = ["lib-infra/dart"]
|
dart = ["lib-infra/dart"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["protobuf_file_gen"] }
|
lib-infra = { path = "../../../shared-lib/lib-infra", features = ["proto_gen"] }
|
65
shared-lib/Cargo.lock
generated
65
shared-lib/Cargo.lock
generated
|
@ -403,6 +403,17 @@ dependencies = [
|
||||||
"protobuf",
|
"protobuf",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "flowy-http-model"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"bytes",
|
||||||
|
"flowy-derive",
|
||||||
|
"lib-infra",
|
||||||
|
"md5",
|
||||||
|
"protobuf",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flowy-sync"
|
name = "flowy-sync"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -413,19 +424,19 @@ dependencies = [
|
||||||
"dashmap",
|
"dashmap",
|
||||||
"dissimilar",
|
"dissimilar",
|
||||||
"flowy-derive",
|
"flowy-derive",
|
||||||
|
"flowy-http-model",
|
||||||
"folder-rev-model",
|
"folder-rev-model",
|
||||||
"futures",
|
"futures",
|
||||||
"grid-rev-model",
|
"grid-rev-model",
|
||||||
"lib-infra",
|
"lib-infra",
|
||||||
"lib-ot",
|
"lib-ot",
|
||||||
"log",
|
"log",
|
||||||
"md5",
|
|
||||||
"parking_lot 0.12.1",
|
"parking_lot 0.12.1",
|
||||||
"protobuf",
|
"protobuf",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"strum 0.21.0",
|
"strum",
|
||||||
"strum_macros 0.21.1",
|
"strum_macros",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"url",
|
"url",
|
||||||
|
@ -447,8 +458,8 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_repr",
|
"serde_repr",
|
||||||
"strum 0.24.1",
|
"strum",
|
||||||
"strum_macros 0.24.3",
|
"strum_macros",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -637,7 +648,6 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_repr",
|
"serde_repr",
|
||||||
"tracing",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -655,12 +665,6 @@ dependencies = [
|
||||||
"unicode-segmentation",
|
"unicode-segmentation",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "heck"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
version = "0.1.19"
|
version = "0.1.19"
|
||||||
|
@ -821,8 +825,8 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_repr",
|
"serde_repr",
|
||||||
"strum 0.21.0",
|
"strum",
|
||||||
"strum_macros 0.21.1",
|
"strum_macros",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
@ -842,12 +846,12 @@ dependencies = [
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"lib-infra",
|
"lib-infra",
|
||||||
"log",
|
"log",
|
||||||
"parking_lot 0.11.2",
|
"parking_lot 0.12.1",
|
||||||
"paste",
|
"paste",
|
||||||
"pin-project",
|
"pin-project",
|
||||||
"protobuf",
|
"protobuf",
|
||||||
"strum 0.21.0",
|
"strum",
|
||||||
"strum_macros 0.21.1",
|
"strum_macros",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-tungstenite",
|
"tokio-tungstenite",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
@ -1498,12 +1502,6 @@ dependencies = [
|
||||||
"semver",
|
"semver",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustversion"
|
|
||||||
version = "1.0.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.5"
|
version = "1.0.5"
|
||||||
|
@ -1658,37 +1656,18 @@ version = "0.21.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aaf86bbcfd1fa9670b7a129f64fc0c9fcbbfe4f1bc4210e9e98fe71ffc12cde2"
|
checksum = "aaf86bbcfd1fa9670b7a129f64fc0c9fcbbfe4f1bc4210e9e98fe71ffc12cde2"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "strum"
|
|
||||||
version = "0.24.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strum_macros"
|
name = "strum_macros"
|
||||||
version = "0.21.1"
|
version = "0.21.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d06aaeeee809dbc59eb4556183dd927df67db1540de5be8d3ec0b6636358a5ec"
|
checksum = "d06aaeeee809dbc59eb4556183dd927df67db1540de5be8d3ec0b6636358a5ec"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck 0.3.3",
|
"heck",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "strum_macros"
|
|
||||||
version = "0.24.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59"
|
|
||||||
dependencies = [
|
|
||||||
"heck 0.4.0",
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"rustversion",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "1.0.81"
|
version = "1.0.81"
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
members = [
|
members = [
|
||||||
"folder-rev-model",
|
"folder-rev-model",
|
||||||
"flowy-sync",
|
"flowy-sync",
|
||||||
|
"flowy-http-model",
|
||||||
"lib-ot",
|
"lib-ot",
|
||||||
"lib-ws",
|
"lib-ws",
|
||||||
"lib-infra",
|
"lib-infra",
|
||||||
|
|
|
@ -11,7 +11,7 @@ protobuf = {version = "2.18.0"}
|
||||||
derive_more = {version = "0.99", features = ["display"]}
|
derive_more = {version = "0.99", features = ["display"]}
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
lib-infra = { path = "../lib-infra", features = ["protobuf_file_gen"] }
|
lib-infra = { path = "../lib-infra", features = ["proto_gen"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
dart = ["lib-infra/dart"]
|
dart = ["lib-infra/dart"]
|
17
shared-lib/flowy-http-model/Cargo.toml
Normal file
17
shared-lib/flowy-http-model/Cargo.toml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
[package]
|
||||||
|
name = "flowy-http-model"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bytes = "1.0"
|
||||||
|
lib-infra = { path = "../lib-infra" }
|
||||||
|
flowy-derive = { path = "../flowy-derive" }
|
||||||
|
protobuf = {version = "2.18.0"}
|
||||||
|
md5 = "0.7.0"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
lib-infra = { path = "../lib-infra", features = ["proto_gen"] }
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
use crate::{
|
use crate::entities::revision::{RepeatedRevision, Revision};
|
||||||
entities::revision::{RepeatedRevision, Revision},
|
|
||||||
errors::CollaborateError,
|
|
||||||
};
|
|
||||||
use flowy_derive::ProtoBuf;
|
use flowy_derive::ProtoBuf;
|
||||||
use lib_ot::text_delta::DeltaTextOperations;
|
|
||||||
|
|
||||||
#[derive(ProtoBuf, Default, Debug, Clone)]
|
#[derive(ProtoBuf, Default, Debug, Clone)]
|
||||||
pub struct CreateDocumentParams {
|
pub struct CreateDocumentParams {
|
||||||
|
@ -20,7 +16,7 @@ pub struct DocumentPayloadPB {
|
||||||
pub doc_id: String,
|
pub doc_id: String,
|
||||||
|
|
||||||
#[pb(index = 2)]
|
#[pb(index = 2)]
|
||||||
pub content: String,
|
pub data: Vec<u8>,
|
||||||
|
|
||||||
#[pb(index = 3)]
|
#[pb(index = 3)]
|
||||||
pub rev_id: i64,
|
pub rev_id: i64,
|
||||||
|
@ -30,20 +26,16 @@ pub struct DocumentPayloadPB {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::convert::TryFrom<Revision> for DocumentPayloadPB {
|
impl std::convert::TryFrom<Revision> for DocumentPayloadPB {
|
||||||
type Error = CollaborateError;
|
type Error = String;
|
||||||
|
|
||||||
fn try_from(revision: Revision) -> Result<Self, Self::Error> {
|
fn try_from(revision: Revision) -> Result<Self, Self::Error> {
|
||||||
if !revision.is_initial() {
|
if !revision.is_initial() {
|
||||||
return Err(CollaborateError::revision_conflict()
|
return Err("Revision's rev_id should be 0 when creating the document".to_string());
|
||||||
.context("Revision's rev_id should be 0 when creating the document"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let delta = DeltaTextOperations::from_bytes(&revision.bytes)?;
|
|
||||||
let doc_json = delta.json_str();
|
|
||||||
|
|
||||||
Ok(DocumentPayloadPB {
|
Ok(DocumentPayloadPB {
|
||||||
doc_id: revision.object_id,
|
doc_id: revision.object_id,
|
||||||
content: doc_json,
|
data: revision.bytes,
|
||||||
rev_id: revision.rev_id,
|
rev_id: revision.rev_id,
|
||||||
base_rev_id: revision.base_rev_id,
|
base_rev_id: revision.base_rev_id,
|
||||||
})
|
})
|
|
@ -1,5 +1,4 @@
|
||||||
pub mod document;
|
pub mod document;
|
||||||
pub mod folder;
|
pub mod folder;
|
||||||
pub mod parser;
|
|
||||||
pub mod revision;
|
pub mod revision;
|
||||||
pub mod ws_data;
|
pub mod ws_data;
|
|
@ -3,8 +3,6 @@ use bytes::Bytes;
|
||||||
use flowy_derive::ProtoBuf;
|
use flowy_derive::ProtoBuf;
|
||||||
use std::{convert::TryFrom, fmt::Formatter, ops::RangeInclusive};
|
use std::{convert::TryFrom, fmt::Formatter, ops::RangeInclusive};
|
||||||
|
|
||||||
pub type RevisionObject = lib_ot::text_delta::DeltaTextOperations;
|
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Default, ProtoBuf)]
|
#[derive(PartialEq, Eq, Clone, Default, ProtoBuf)]
|
||||||
pub struct Revision {
|
pub struct Revision {
|
||||||
#[pb(index = 1)]
|
#[pb(index = 1)]
|
||||||
|
@ -73,14 +71,6 @@ impl std::fmt::Debug for Revision {
|
||||||
let _ = f.write_fmt(format_args!("object_id {}, ", self.object_id))?;
|
let _ = f.write_fmt(format_args!("object_id {}, ", self.object_id))?;
|
||||||
let _ = f.write_fmt(format_args!("base_rev_id {}, ", self.base_rev_id))?;
|
let _ = f.write_fmt(format_args!("base_rev_id {}, ", self.base_rev_id))?;
|
||||||
let _ = f.write_fmt(format_args!("rev_id {}, ", self.rev_id))?;
|
let _ = f.write_fmt(format_args!("rev_id {}, ", self.rev_id))?;
|
||||||
match RevisionObject::from_bytes(&self.bytes) {
|
|
||||||
Ok(object) => {
|
|
||||||
let _ = f.write_fmt(format_args!("object {:?}", object.json_str()))?;
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
let _ = f.write_fmt(format_args!("object {:?}", e))?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,7 @@
|
||||||
use crate::{
|
use crate::entities::revision::{RepeatedRevision, RevId, Revision, RevisionRange};
|
||||||
entities::revision::{RepeatedRevision, RevId, Revision, RevisionRange},
|
|
||||||
errors::CollaborateError,
|
|
||||||
};
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
|
||||||
use std::convert::{TryFrom, TryInto};
|
use std::convert::TryInto;
|
||||||
|
|
||||||
#[derive(Debug, Clone, ProtoBuf_Enum, Eq, PartialEq, Hash)]
|
#[derive(Debug, Clone, ProtoBuf_Enum, Eq, PartialEq, Hash)]
|
||||||
pub enum ClientRevisionWSDataType {
|
pub enum ClientRevisionWSDataType {
|
||||||
|
@ -12,16 +9,16 @@ pub enum ClientRevisionWSDataType {
|
||||||
ClientPing = 1,
|
ClientPing = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClientRevisionWSDataType {
|
// impl ClientRevisionWSDataType {
|
||||||
pub fn data<T>(&self, bytes: Bytes) -> Result<T, CollaborateError>
|
// pub fn data<T>(&self, bytes: Bytes) -> Result<T, String>
|
||||||
where
|
// where
|
||||||
T: TryFrom<Bytes, Error = CollaborateError>,
|
// T: TryFrom<Bytes, Error = String>,
|
||||||
{
|
// {
|
||||||
T::try_from(bytes)
|
// T::try_from(bytes)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
impl std::default::Default for ClientRevisionWSDataType {
|
impl Default for ClientRevisionWSDataType {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
ClientRevisionWSDataType::ClientPushRev
|
ClientRevisionWSDataType::ClientPushRev
|
||||||
}
|
}
|
||||||
|
@ -39,7 +36,7 @@ pub struct ClientRevisionWSData {
|
||||||
pub revisions: RepeatedRevision,
|
pub revisions: RepeatedRevision,
|
||||||
|
|
||||||
#[pb(index = 4)]
|
#[pb(index = 4)]
|
||||||
data_id: String,
|
pub data_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClientRevisionWSData {
|
impl ClientRevisionWSData {
|
||||||
|
@ -79,7 +76,7 @@ pub enum ServerRevisionWSDataType {
|
||||||
UserConnect = 3,
|
UserConnect = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::default::Default for ServerRevisionWSDataType {
|
impl Default for ServerRevisionWSDataType {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
ServerRevisionWSDataType::ServerPushRev
|
ServerRevisionWSDataType::ServerPushRev
|
||||||
}
|
}
|
6
shared-lib/flowy-http-model/src/lib.rs
Normal file
6
shared-lib/flowy-http-model/src/lib.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
pub mod util;
|
||||||
|
|
||||||
|
pub mod protobuf;
|
||||||
|
|
||||||
|
mod entities;
|
||||||
|
pub use entities::*;
|
5
shared-lib/flowy-http-model/src/util.rs
Normal file
5
shared-lib/flowy-http-model/src/util.rs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#[inline]
|
||||||
|
pub fn md5<T: AsRef<[u8]>>(data: T) -> String {
|
||||||
|
let md5 = format!("{:x}", md5::compute(data));
|
||||||
|
md5
|
||||||
|
}
|
|
@ -11,10 +11,10 @@ lib-infra = { path = "../lib-infra" }
|
||||||
flowy-derive = { path = "../flowy-derive" }
|
flowy-derive = { path = "../flowy-derive" }
|
||||||
folder-rev-model = { path = "../folder-rev-model" }
|
folder-rev-model = { path = "../folder-rev-model" }
|
||||||
grid-rev-model = { path = "../grid-rev-model" }
|
grid-rev-model = { path = "../grid-rev-model" }
|
||||||
|
flowy-http-model= { path = "../flowy-http-model" }
|
||||||
protobuf = {version = "2.18.0"}
|
protobuf = {version = "2.18.0"}
|
||||||
bytes = "1.0"
|
bytes = "1.0"
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
||||||
md5 = "0.7.0"
|
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
serde = { version = "1.0", features = ["derive", "rc"] }
|
serde = { version = "1.0", features = ["derive", "rc"] }
|
||||||
serde_json = {version = "1.0"}
|
serde_json = {version = "1.0"}
|
||||||
|
@ -28,9 +28,3 @@ parking_lot = "0.12.1"
|
||||||
dashmap = "5"
|
dashmap = "5"
|
||||||
futures = "0.3.15"
|
futures = "0.3.15"
|
||||||
async-stream = "0.3.2"
|
async-stream = "0.3.2"
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
lib-infra = { path = "../lib-infra", features = ["protobuf_file_gen"] }
|
|
||||||
|
|
||||||
[features]
|
|
||||||
dart = ["lib-infra/dart"]
|
|
|
@ -1,4 +1,3 @@
|
||||||
use crate::util::md5;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
client_document::{
|
client_document::{
|
||||||
history::{History, UndoResult},
|
history::{History, UndoResult},
|
||||||
|
@ -7,6 +6,7 @@ use crate::{
|
||||||
errors::CollaborateError,
|
errors::CollaborateError,
|
||||||
};
|
};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
use flowy_http_model::util::md5;
|
||||||
use lib_ot::text_delta::DeltaTextOperationBuilder;
|
use lib_ot::text_delta::DeltaTextOperationBuilder;
|
||||||
use lib_ot::{core::*, text_delta::DeltaTextOperations};
|
use lib_ot::{core::*, text_delta::DeltaTextOperations};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
use crate::util::make_operations_from_revisions;
|
use crate::util::make_operations_from_revisions;
|
||||||
use crate::{
|
use crate::{
|
||||||
client_folder::{default_folder_operations, FolderPad},
|
client_folder::{default_folder_operations, FolderPad},
|
||||||
entities::revision::Revision,
|
|
||||||
errors::CollaborateResult,
|
errors::CollaborateResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::server_folder::FolderOperations;
|
use crate::server_folder::FolderOperations;
|
||||||
|
use flowy_http_model::revision::Revision;
|
||||||
use folder_rev_model::{TrashRevision, WorkspaceRevision};
|
use folder_rev_model::{TrashRevision, WorkspaceRevision};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use crate::errors::internal_error;
|
use crate::errors::internal_error;
|
||||||
use crate::server_folder::{FolderOperations, FolderOperationsBuilder};
|
use crate::server_folder::{FolderOperations, FolderOperationsBuilder};
|
||||||
use crate::util::{cal_diff, md5};
|
use crate::util::cal_diff;
|
||||||
use crate::{
|
use crate::{
|
||||||
client_folder::builder::FolderPadBuilder,
|
client_folder::builder::FolderPadBuilder,
|
||||||
entities::revision::Revision,
|
|
||||||
errors::{CollaborateError, CollaborateResult},
|
errors::{CollaborateError, CollaborateResult},
|
||||||
};
|
};
|
||||||
|
use flowy_http_model::revision::Revision;
|
||||||
|
use flowy_http_model::util::md5;
|
||||||
use folder_rev_model::{AppRevision, FolderRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
use folder_rev_model::{AppRevision, FolderRevision, TrashRevision, ViewRevision, WorkspaceRevision};
|
||||||
use lib_infra::util::move_vec_element;
|
use lib_infra::util::move_vec_element;
|
||||||
use lib_ot::core::*;
|
use lib_ot::core::*;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::entities::revision::{RepeatedRevision, Revision};
|
|
||||||
use crate::errors::{CollaborateError, CollaborateResult};
|
use crate::errors::{CollaborateError, CollaborateResult};
|
||||||
use crate::util::{cal_diff, make_operations_from_revisions, md5};
|
use crate::util::{cal_diff, make_operations_from_revisions};
|
||||||
|
use flowy_http_model::revision::{RepeatedRevision, Revision};
|
||||||
|
use flowy_http_model::util::md5;
|
||||||
use grid_rev_model::{gen_block_id, gen_row_id, CellRevision, GridBlockRevision, RowChangeset, RowRevision};
|
use grid_rev_model::{gen_block_id, gen_row_id, CellRevision, GridBlockRevision, RowChangeset, RowRevision};
|
||||||
use lib_ot::core::{DeltaBuilder, DeltaOperations, EmptyAttributes, OperationTransform};
|
use lib_ot::core::{DeltaBuilder, DeltaOperations, EmptyAttributes, OperationTransform};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::entities::revision::{RepeatedRevision, Revision};
|
|
||||||
use crate::errors::{internal_error, CollaborateError, CollaborateResult};
|
use crate::errors::{internal_error, CollaborateError, CollaborateResult};
|
||||||
use crate::util::{cal_diff, make_operations_from_revisions, md5};
|
use crate::util::{cal_diff, make_operations_from_revisions};
|
||||||
|
use flowy_http_model::revision::{RepeatedRevision, Revision};
|
||||||
|
use flowy_http_model::util::md5;
|
||||||
use grid_rev_model::{
|
use grid_rev_model::{
|
||||||
gen_block_id, gen_grid_id, FieldRevision, FieldTypeRevision, GridBlockMetaRevision, GridBlockMetaRevisionChangeset,
|
gen_block_id, gen_grid_id, FieldRevision, FieldTypeRevision, GridBlockMetaRevision, GridBlockMetaRevisionChangeset,
|
||||||
GridRevision,
|
GridRevision,
|
||||||
|
@ -10,6 +10,7 @@ use lib_infra::util::move_vec_element;
|
||||||
use lib_ot::core::{DeltaOperationBuilder, DeltaOperations, EmptyAttributes, OperationTransform};
|
use lib_ot::core::{DeltaOperationBuilder, DeltaOperations, EmptyAttributes, OperationTransform};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub type GridOperations = DeltaOperations<EmptyAttributes>;
|
pub type GridOperations = DeltaOperations<EmptyAttributes>;
|
||||||
pub type GridOperationsBuilder = DeltaOperationBuilder<EmptyAttributes>;
|
pub type GridOperationsBuilder = DeltaOperationBuilder<EmptyAttributes>;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::entities::revision::Revision;
|
|
||||||
use crate::errors::{internal_error, CollaborateError, CollaborateResult};
|
use crate::errors::{internal_error, CollaborateError, CollaborateResult};
|
||||||
use crate::util::{cal_diff, make_operations_from_revisions, md5};
|
use crate::util::{cal_diff, make_operations_from_revisions};
|
||||||
|
use flowy_http_model::revision::Revision;
|
||||||
|
use flowy_http_model::util::md5;
|
||||||
use grid_rev_model::{
|
use grid_rev_model::{
|
||||||
FieldRevision, FieldTypeRevision, FilterConfigurationRevision, FilterConfigurationsByFieldId, GridViewRevision,
|
FieldRevision, FieldTypeRevision, FilterConfigurationRevision, FilterConfigurationsByFieldId, GridViewRevision,
|
||||||
GroupConfigurationRevision, GroupConfigurationsByFieldId, LayoutRevision,
|
GroupConfigurationRevision, GroupConfigurationsByFieldId, LayoutRevision,
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct DocumentIdentify(pub String);
|
|
||||||
|
|
||||||
impl DocumentIdentify {
|
|
||||||
pub fn parse(s: String) -> Result<DocumentIdentify, String> {
|
|
||||||
if s.trim().is_empty() {
|
|
||||||
return Err("Doc id can not be empty or whitespace".to_string());
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Self(s))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AsRef<str> for DocumentIdentify {
|
|
||||||
fn as_ref(&self) -> &str {
|
|
||||||
&self.0
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
mod doc_id;
|
|
||||||
|
|
||||||
pub use doc_id::*;
|
|
|
@ -1,9 +1,7 @@
|
||||||
pub mod client_document;
|
pub mod client_document;
|
||||||
pub mod client_folder;
|
pub mod client_folder;
|
||||||
pub mod client_grid;
|
pub mod client_grid;
|
||||||
pub mod entities;
|
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
pub mod protobuf;
|
|
||||||
pub mod server_document;
|
pub mod server_document;
|
||||||
pub mod server_folder;
|
pub mod server_folder;
|
||||||
pub mod synchronizer;
|
pub mod synchronizer;
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
use crate::entities::revision::{RepeatedRevision, Revision};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
entities::{document::DocumentPayloadPB, ws_data::ServerRevisionWSDataBuilder},
|
|
||||||
errors::{internal_error, CollaborateError, CollaborateResult},
|
errors::{internal_error, CollaborateError, CollaborateResult},
|
||||||
protobuf::ClientRevisionWSData,
|
|
||||||
server_document::document_pad::ServerDocument,
|
server_document::document_pad::ServerDocument,
|
||||||
synchronizer::{RevisionSyncPersistence, RevisionSyncResponse, RevisionSynchronizer, RevisionUser},
|
synchronizer::{RevisionSyncPersistence, RevisionSyncResponse, RevisionSynchronizer, RevisionUser},
|
||||||
util::rev_id_from_str,
|
util::rev_id_from_str,
|
||||||
};
|
};
|
||||||
use async_stream::stream;
|
use async_stream::stream;
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
|
use flowy_http_model::document::DocumentPayloadPB;
|
||||||
|
use flowy_http_model::protobuf::ClientRevisionWSData;
|
||||||
|
use flowy_http_model::revision::{RepeatedRevision, Revision};
|
||||||
|
use flowy_http_model::ws_data::ServerRevisionWSDataBuilder;
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
use lib_infra::future::BoxResultFuture;
|
use lib_infra::future::BoxResultFuture;
|
||||||
use lib_ot::core::AttributeHashMap;
|
use lib_ot::core::AttributeHashMap;
|
||||||
|
@ -216,7 +217,7 @@ impl OpenDocumentHandler {
|
||||||
let (sender, receiver) = mpsc::channel(1000);
|
let (sender, receiver) = mpsc::channel(1000);
|
||||||
let users = DashMap::new();
|
let users = DashMap::new();
|
||||||
|
|
||||||
let operations = DeltaTextOperations::from_bytes(&doc.content)?;
|
let operations = DeltaTextOperations::from_bytes(&doc.data)?;
|
||||||
let sync_object = ServerDocument::from_operations(&doc_id, operations);
|
let sync_object = ServerDocument::from_operations(&doc_id, operations);
|
||||||
let synchronizer = Arc::new(DocumentRevisionSynchronizer::new(doc.rev_id, sync_object, persistence));
|
let synchronizer = Arc::new(DocumentRevisionSynchronizer::new(doc.rev_id, sync_object, persistence));
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
use crate::entities::revision::{RepeatedRevision, Revision};
|
|
||||||
use crate::server_folder::folder_pad::{FolderOperations, FolderRevisionSynchronizer};
|
use crate::server_folder::folder_pad::{FolderOperations, FolderRevisionSynchronizer};
|
||||||
use crate::{
|
use crate::{
|
||||||
entities::{folder::FolderInfo, ws_data::ServerRevisionWSDataBuilder},
|
|
||||||
errors::{internal_error, CollaborateError, CollaborateResult},
|
errors::{internal_error, CollaborateError, CollaborateResult},
|
||||||
protobuf::ClientRevisionWSData,
|
|
||||||
server_folder::folder_pad::ServerFolder,
|
server_folder::folder_pad::ServerFolder,
|
||||||
synchronizer::{RevisionSyncPersistence, RevisionSyncResponse, RevisionUser},
|
synchronizer::{RevisionSyncPersistence, RevisionSyncResponse, RevisionUser},
|
||||||
util::rev_id_from_str,
|
util::rev_id_from_str,
|
||||||
};
|
};
|
||||||
use async_stream::stream;
|
use async_stream::stream;
|
||||||
|
use flowy_http_model::folder::FolderInfo;
|
||||||
|
use flowy_http_model::protobuf::ClientRevisionWSData;
|
||||||
|
use flowy_http_model::revision::{RepeatedRevision, Revision};
|
||||||
|
use flowy_http_model::ws_data::ServerRevisionWSDataBuilder;
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
use lib_infra::future::BoxResultFuture;
|
use lib_infra::future::BoxResultFuture;
|
||||||
use std::{collections::HashMap, fmt::Debug, sync::Arc};
|
use std::{collections::HashMap, fmt::Debug, sync::Arc};
|
||||||
|
|
|
@ -1,13 +1,6 @@
|
||||||
use crate::entities::revision::{RepeatedRevision, Revision};
|
use crate::{errors::CollaborateError, util::*};
|
||||||
use crate::{
|
use flowy_http_model::revision::{RepeatedRevision, Revision, RevisionRange};
|
||||||
entities::{
|
use flowy_http_model::ws_data::{ServerRevisionWSData, ServerRevisionWSDataBuilder};
|
||||||
revision::RevisionRange,
|
|
||||||
ws_data::{ServerRevisionWSData, ServerRevisionWSDataBuilder},
|
|
||||||
},
|
|
||||||
errors::CollaborateError,
|
|
||||||
protobuf::Revision as RevisionPB,
|
|
||||||
util::*,
|
|
||||||
};
|
|
||||||
use lib_infra::future::BoxResultFuture;
|
use lib_infra::future::BoxResultFuture;
|
||||||
use lib_ot::core::{DeltaOperations, OperationAttributes};
|
use lib_ot::core::{DeltaOperations, OperationAttributes};
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
|
@ -207,7 +200,7 @@ where
|
||||||
#[tracing::instrument(level = "debug", skip(self, revision))]
|
#[tracing::instrument(level = "debug", skip(self, revision))]
|
||||||
fn transform_revision(
|
fn transform_revision(
|
||||||
&self,
|
&self,
|
||||||
revision: &RevisionPB,
|
revision: &flowy_http_model::protobuf::Revision,
|
||||||
) -> Result<(RevisionOperations<Attribute>, RevisionOperations<Attribute>), CollaborateError> {
|
) -> Result<(RevisionOperations<Attribute>, RevisionOperations<Attribute>), CollaborateError> {
|
||||||
let client_operations = RevisionOperations::<Attribute>::from_bytes(&revision.bytes)?;
|
let client_operations = RevisionOperations::<Attribute>::from_bytes(&revision.bytes)?;
|
||||||
let result = self.object.read().transform(&client_operations)?;
|
let result = self.object.read().transform(&client_operations)?;
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
|
use crate::errors::{CollaborateError, CollaborateResult};
|
||||||
use crate::server_folder::FolderOperations;
|
use crate::server_folder::FolderOperations;
|
||||||
use crate::{
|
|
||||||
entities::{
|
|
||||||
document::DocumentPayloadPB,
|
|
||||||
folder::FolderInfo,
|
|
||||||
revision::{RepeatedRevision, Revision},
|
|
||||||
},
|
|
||||||
errors::{CollaborateError, CollaborateResult},
|
|
||||||
};
|
|
||||||
use dissimilar::Chunk;
|
use dissimilar::Chunk;
|
||||||
|
use flowy_http_model::document::DocumentPayloadPB;
|
||||||
|
use flowy_http_model::folder::FolderInfo;
|
||||||
|
use flowy_http_model::revision::RepeatedRevision;
|
||||||
|
use flowy_http_model::revision::Revision;
|
||||||
use lib_ot::core::{DeltaOperationBuilder, OTString, OperationAttributes};
|
use lib_ot::core::{DeltaOperationBuilder, OTString, OperationAttributes};
|
||||||
use lib_ot::{
|
use lib_ot::{
|
||||||
core::{DeltaOperations, OperationTransform, NEW_LINE, WHITESPACE},
|
core::{DeltaOperations, OperationTransform, NEW_LINE, WHITESPACE},
|
||||||
text_delta::DeltaTextOperations,
|
text_delta::DeltaTextOperations,
|
||||||
};
|
};
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
use std::sync::atomic::{AtomicI64, Ordering::SeqCst};
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn find_newline(s: &str) -> Option<usize> {
|
pub fn find_newline(s: &str) -> Option<usize> {
|
||||||
|
@ -36,33 +32,6 @@ pub fn contain_newline(s: &str) -> bool {
|
||||||
s.contains(NEW_LINE)
|
s.contains(NEW_LINE)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn md5<T: AsRef<[u8]>>(data: T) -> String {
|
|
||||||
let md5 = format!("{:x}", md5::compute(data));
|
|
||||||
md5
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct RevIdCounter(pub AtomicI64);
|
|
||||||
|
|
||||||
impl RevIdCounter {
|
|
||||||
pub fn new(n: i64) -> Self {
|
|
||||||
Self(AtomicI64::new(n))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn next_id(&self) -> i64 {
|
|
||||||
let _ = self.0.fetch_add(1, SeqCst);
|
|
||||||
self.value()
|
|
||||||
}
|
|
||||||
pub fn value(&self) -> i64 {
|
|
||||||
self.0.load(SeqCst)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set(&self, n: i64) {
|
|
||||||
let _ = self.0.fetch_update(SeqCst, SeqCst, |_| Some(n));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tracing::instrument(level = "trace", skip(revisions), err)]
|
#[tracing::instrument(level = "trace", skip(revisions), err)]
|
||||||
pub fn make_operations_from_revisions<T>(revisions: Vec<Revision>) -> CollaborateResult<DeltaOperations<T>>
|
pub fn make_operations_from_revisions<T>(revisions: Vec<Revision>) -> CollaborateResult<DeltaOperations<T>>
|
||||||
where
|
where
|
||||||
|
@ -99,21 +68,6 @@ pub fn pair_rev_id_from_revision_pbs(revisions: &[Revision]) -> (i64, i64) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pair_rev_id_from_revisions(revisions: &[Revision]) -> (i64, i64) {
|
|
||||||
let mut rev_id = 0;
|
|
||||||
revisions.iter().for_each(|revision| {
|
|
||||||
if rev_id < revision.rev_id {
|
|
||||||
rev_id = revision.rev_id;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if rev_id > 0 {
|
|
||||||
(rev_id - 1, rev_id)
|
|
||||||
} else {
|
|
||||||
(0, rev_id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn make_folder_from_revisions_pb(
|
pub fn make_folder_from_revisions_pb(
|
||||||
folder_id: &str,
|
folder_id: &str,
|
||||||
|
@ -171,11 +125,9 @@ pub fn make_document_from_revision_pbs(
|
||||||
delta = delta.compose(&new_delta)?;
|
delta = delta.compose(&new_delta)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let text = delta.json_str();
|
|
||||||
|
|
||||||
Ok(Some(DocumentPayloadPB {
|
Ok(Some(DocumentPayloadPB {
|
||||||
doc_id: doc_id.to_owned(),
|
doc_id: doc_id.to_owned(),
|
||||||
content: text,
|
data: delta.json_bytes().to_vec(),
|
||||||
rev_id,
|
rev_id,
|
||||||
base_rev_id,
|
base_rev_id,
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -45,8 +45,11 @@ proto_gen = [
|
||||||
"phf",
|
"phf",
|
||||||
"walkdir",
|
"walkdir",
|
||||||
"console",
|
"console",
|
||||||
"toml"
|
"toml",
|
||||||
|
"cmd_lib",
|
||||||
|
"protoc-rust",
|
||||||
|
"walkdir",
|
||||||
|
"protoc-bin-vendored",
|
||||||
]
|
]
|
||||||
protobuf_file_gen = ["cmd_lib", "protoc-rust", "walkdir", "protoc-bin-vendored",]
|
|
||||||
dart_event = ["walkdir", "flowy-ast", "tera", "syn"]
|
dart_event = ["walkdir", "flowy-ast", "tera", "syn"]
|
||||||
dart = ["proto_gen", "dart_event"]
|
dart = ["proto_gen", "dart_event"]
|
|
@ -1,13 +1,13 @@
|
||||||
#[cfg(feature = "protobuf_file_gen")]
|
#[cfg(feature = "proto_gen")]
|
||||||
pub mod protobuf_file;
|
pub mod protobuf_file;
|
||||||
|
|
||||||
#[cfg(feature = "dart_event")]
|
#[cfg(feature = "dart_event")]
|
||||||
pub mod dart_event;
|
pub mod dart_event;
|
||||||
|
|
||||||
#[cfg(any(feature = "protobuf_file_gen", feature = "dart_event"))]
|
#[cfg(any(feature = "proto_gen", feature = "dart_event"))]
|
||||||
mod flowy_toml;
|
mod flowy_toml;
|
||||||
|
|
||||||
#[cfg(any(feature = "protobuf_file_gen", feature = "dart_event"))]
|
#[cfg(any(feature = "proto_gen", feature = "dart_event"))]
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
|
||||||
#[derive(serde::Serialize, serde::Deserialize)]
|
#[derive(serde::Serialize, serde::Deserialize)]
|
||||||
|
|
|
@ -28,7 +28,7 @@ parking_lot = "0.12.1"
|
||||||
dashmap = "5"
|
dashmap = "5"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
lib-infra = { path = "../lib-infra", features = ["protobuf_file_gen"] }
|
lib-infra = { path = "../lib-infra", features = ["proto_gen"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = {version = "1", features = ["full"]}
|
tokio = {version = "1", features = ["full"]}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue