chore: remove lru (#5008)

* chore: remove lru

* chore: update logs

* chore: clippy
This commit is contained in:
Nathan.fooo 2024-03-30 16:28:24 +08:00 committed by GitHub
parent c2c84a5812
commit adc2ee755e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
33 changed files with 384 additions and 317 deletions

View File

@ -93,7 +93,8 @@ jobs:
af_cloud_test_base_url: http://localhost af_cloud_test_base_url: http://localhost
af_cloud_test_ws_url: ws://localhost/ws/v1 af_cloud_test_ws_url: ws://localhost/ws/v1
af_cloud_test_gotrue_url: http://localhost/gotrue af_cloud_test_gotrue_url: http://localhost/gotrue
run: cargo test --no-default-features --features="rev-sqlite,dart" -- --nocapture run: |
DISABLE_CI_TEST_LOG="true" cargo test --no-default-features --features="rev-sqlite,dart" -- --nocapture
- name: rustfmt rust-lib - name: rustfmt rust-lib
run: cargo fmt --all -- --check run: cargo fmt --all -- --check

View File

@ -132,12 +132,6 @@ dependencies = [
"alloc-no-stdlib", "alloc-no-stdlib",
] ]
[[package]]
name = "allocator-api2"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
[[package]] [[package]]
name = "android-tzdata" name = "android-tzdata"
version = "0.1.1" version = "0.1.1"
@ -162,7 +156,7 @@ checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]] [[package]]
name = "app-error" name = "app-error"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -716,7 +710,7 @@ dependencies = [
[[package]] [[package]]
name = "client-api" name = "client-api"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"again", "again",
"anyhow", "anyhow",
@ -764,7 +758,7 @@ dependencies = [
[[package]] [[package]]
name = "client-websocket" name = "client-websocket"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-util", "futures-util",
@ -838,7 +832,7 @@ dependencies = [
[[package]] [[package]]
name = "collab" name = "collab"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -862,7 +856,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-database" name = "collab-database"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -870,10 +864,10 @@ dependencies = [
"collab", "collab",
"collab-entity", "collab-entity",
"collab-plugins", "collab-plugins",
"dashmap",
"getrandom 0.2.10", "getrandom 0.2.10",
"js-sys", "js-sys",
"lazy_static", "lazy_static",
"lru",
"nanoid", "nanoid",
"parking_lot 0.12.1", "parking_lot 0.12.1",
"rayon", "rayon",
@ -892,7 +886,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-document" name = "collab-document"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -911,7 +905,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-entity" name = "collab-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -926,7 +920,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-folder" name = "collab-folder"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@ -964,7 +958,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-plugins" name = "collab-plugins"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-stream", "async-stream",
@ -1003,7 +997,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-rt-entity" name = "collab-rt-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -1028,7 +1022,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-rt-protocol" name = "collab-rt-protocol"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -1041,7 +1035,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-user" name = "collab-user"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -1375,7 +1369,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]] [[package]]
name = "database-entity" name = "database-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -1879,7 +1873,6 @@ dependencies = [
"lazy_static", "lazy_static",
"lib-dispatch", "lib-dispatch",
"lib-infra", "lib-infra",
"lru",
"nanoid", "nanoid",
"parking_lot 0.12.1", "parking_lot 0.12.1",
"protobuf", "protobuf",
@ -1940,6 +1933,7 @@ dependencies = [
"collab-entity", "collab-entity",
"collab-integrate", "collab-integrate",
"collab-plugins", "collab-plugins",
"dashmap",
"flowy-codegen", "flowy-codegen",
"flowy-derive", "flowy-derive",
"flowy-document-pub", "flowy-document-pub",
@ -1951,7 +1945,6 @@ dependencies = [
"indexmap 2.1.0", "indexmap 2.1.0",
"lib-dispatch", "lib-dispatch",
"lib-infra", "lib-infra",
"lru",
"nanoid", "nanoid",
"parking_lot 0.12.1", "parking_lot 0.12.1",
"protobuf", "protobuf",
@ -2677,7 +2670,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue" name = "gotrue"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"futures-util", "futures-util",
@ -2694,7 +2687,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue-entity" name = "gotrue-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -2811,10 +2804,6 @@ name = "hashbrown"
version = "0.14.3" version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
dependencies = [
"ahash 0.8.6",
"allocator-api2",
]
[[package]] [[package]]
name = "heck" name = "heck"
@ -3149,7 +3138,7 @@ dependencies = [
[[package]] [[package]]
name = "infra" name = "infra"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"reqwest", "reqwest",
@ -3507,15 +3496,6 @@ dependencies = [
"tracing-subscriber", "tracing-subscriber",
] ]
[[package]]
name = "lru"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1efa59af2ddfad1854ae27d75009d538d0998b4b2fd47083e743ac1a10e46c60"
dependencies = [
"hashbrown 0.14.3",
]
[[package]] [[package]]
name = "mac" name = "mac"
version = "0.1.1" version = "0.1.1"
@ -5591,7 +5571,7 @@ dependencies = [
[[package]] [[package]]
name = "shared-entity" name = "shared-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -7554,7 +7534,7 @@ dependencies = [
[[package]] [[package]]
name = "workspace-template" name = "workspace-template"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",

View File

@ -29,7 +29,6 @@ tokio = "1.34.0"
tokio-stream = "0.1.14" tokio-stream = "0.1.14"
async-trait = "0.1.74" async-trait = "0.1.74"
chrono = { version = "0.4.31", default-features = false, features = ["clock"] } chrono = { version = "0.4.31", default-features = false, features = ["clock"] }
lru = "0.12.0"
[dependencies] [dependencies]
serde_json.workspace = true serde_json.workspace = true
@ -86,7 +85,7 @@ custom-protocol = ["tauri/custom-protocol"]
# Run the script: # Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id # scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "d77fb77a3a1df1dec14db68bebe35d911d9ae437" } client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "0821c052f996b56ec42b86c9462f065e4639d735" }
# Please use the following script to update collab. # Please use the following script to update collab.
# Working directory: frontend # Working directory: frontend
# #
@ -96,10 +95,10 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "d77
# To switch to the local path, run: # To switch to the local path, run:
# scripts/tool/update_collab_source.sh # scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }

View File

@ -191,12 +191,6 @@ dependencies = [
"alloc-no-stdlib", "alloc-no-stdlib",
] ]
[[package]]
name = "allocator-api2"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
[[package]] [[package]]
name = "android-tzdata" name = "android-tzdata"
version = "0.1.1" version = "0.1.1"
@ -221,7 +215,7 @@ checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]] [[package]]
name = "app-error" name = "app-error"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -545,7 +539,7 @@ dependencies = [
[[package]] [[package]]
name = "client-api" name = "client-api"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"again", "again",
"anyhow", "anyhow",
@ -592,7 +586,7 @@ dependencies = [
[[package]] [[package]]
name = "client-websocket" name = "client-websocket"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-util", "futures-util",
@ -636,7 +630,7 @@ dependencies = [
[[package]] [[package]]
name = "collab" name = "collab"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -660,7 +654,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-document" name = "collab-document"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -679,7 +673,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-entity" name = "collab-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -694,7 +688,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-folder" name = "collab-folder"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@ -732,7 +726,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-plugins" name = "collab-plugins"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-stream", "async-stream",
@ -770,7 +764,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-rt-entity" name = "collab-rt-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -795,7 +789,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-rt-protocol" name = "collab-rt-protocol"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -808,7 +802,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-user" name = "collab-user"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -1005,7 +999,7 @@ checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5"
[[package]] [[package]]
name = "database-entity" name = "database-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -1292,6 +1286,7 @@ dependencies = [
"collab-entity", "collab-entity",
"collab-integrate", "collab-integrate",
"collab-plugins", "collab-plugins",
"dashmap",
"flowy-codegen", "flowy-codegen",
"flowy-derive", "flowy-derive",
"flowy-document-pub", "flowy-document-pub",
@ -1303,7 +1298,6 @@ dependencies = [
"indexmap", "indexmap",
"lib-dispatch", "lib-dispatch",
"lib-infra", "lib-infra",
"lru",
"nanoid", "nanoid",
"parking_lot 0.12.1", "parking_lot 0.12.1",
"protobuf", "protobuf",
@ -1760,7 +1754,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue" name = "gotrue"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"futures-util", "futures-util",
@ -1777,7 +1771,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue-entity" name = "gotrue-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -1830,10 +1824,6 @@ name = "hashbrown"
version = "0.14.3" version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
dependencies = [
"ahash",
"allocator-api2",
]
[[package]] [[package]]
name = "heck" name = "heck"
@ -2111,7 +2101,7 @@ dependencies = [
[[package]] [[package]]
name = "infra" name = "infra"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"reqwest", "reqwest",
@ -2331,15 +2321,6 @@ version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "lru"
version = "0.12.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db2c024b41519440580066ba82aab04092b333e09066a5eb86c7c4890df31f22"
dependencies = [
"hashbrown",
]
[[package]] [[package]]
name = "mac" name = "mac"
version = "0.1.1" version = "0.1.1"
@ -3795,7 +3776,7 @@ dependencies = [
[[package]] [[package]]
name = "shared-entity" name = "shared-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -5027,4 +5008,4 @@ dependencies = [
[[patch.unused]] [[patch.unused]]
name = "collab-database" name = "collab-database"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"

View File

@ -55,7 +55,7 @@ codegen-units = 1
# Run the script: # Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id # scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "d77fb77a3a1df1dec14db68bebe35d911d9ae437" } client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "0821c052f996b56ec42b86c9462f065e4639d735" }
# Please use the following script to update collab. # Please use the following script to update collab.
# Working directory: frontend # Working directory: frontend
# #
@ -65,10 +65,10 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "d77
# To switch to the local path, run: # To switch to the local path, run:
# scripts/tool/update_collab_source.sh # scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }

View File

@ -133,12 +133,6 @@ dependencies = [
"alloc-no-stdlib", "alloc-no-stdlib",
] ]
[[package]]
name = "allocator-api2"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
[[package]] [[package]]
name = "android-tzdata" name = "android-tzdata"
version = "0.1.1" version = "0.1.1"
@ -163,7 +157,7 @@ checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]] [[package]]
name = "app-error" name = "app-error"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -673,7 +667,7 @@ dependencies = [
[[package]] [[package]]
name = "client-api" name = "client-api"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"again", "again",
"anyhow", "anyhow",
@ -721,7 +715,7 @@ dependencies = [
[[package]] [[package]]
name = "client-websocket" name = "client-websocket"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-util", "futures-util",
@ -764,7 +758,7 @@ dependencies = [
[[package]] [[package]]
name = "collab" name = "collab"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -788,7 +782,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-database" name = "collab-database"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
@ -796,10 +790,10 @@ dependencies = [
"collab", "collab",
"collab-entity", "collab-entity",
"collab-plugins", "collab-plugins",
"dashmap",
"getrandom 0.2.10", "getrandom 0.2.10",
"js-sys", "js-sys",
"lazy_static", "lazy_static",
"lru",
"nanoid", "nanoid",
"parking_lot 0.12.1", "parking_lot 0.12.1",
"rayon", "rayon",
@ -818,7 +812,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-document" name = "collab-document"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -837,7 +831,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-entity" name = "collab-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -852,7 +846,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-folder" name = "collab-folder"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"chrono", "chrono",
@ -890,7 +884,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-plugins" name = "collab-plugins"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-stream", "async-stream",
@ -929,7 +923,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-rt-entity" name = "collab-rt-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -954,7 +948,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-rt-protocol" name = "collab-rt-protocol"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bincode", "bincode",
@ -967,7 +961,7 @@ dependencies = [
[[package]] [[package]]
name = "collab-user" name = "collab-user"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=c08d23f5a1f9f0de9465a3b248aedeaf8cd65381#c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=ab468ea96a15863d1e792ea4bed3a8769f3ea8a7#ab468ea96a15863d1e792ea4bed3a8769f3ea8a7"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"collab", "collab",
@ -1297,7 +1291,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]] [[package]]
name = "database-entity" name = "database-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -1838,7 +1832,6 @@ dependencies = [
"lazy_static", "lazy_static",
"lib-dispatch", "lib-dispatch",
"lib-infra", "lib-infra",
"lru",
"nanoid", "nanoid",
"parking_lot 0.12.1", "parking_lot 0.12.1",
"protobuf", "protobuf",
@ -1899,6 +1892,7 @@ dependencies = [
"collab-entity", "collab-entity",
"collab-integrate", "collab-integrate",
"collab-plugins", "collab-plugins",
"dashmap",
"flowy-codegen", "flowy-codegen",
"flowy-derive", "flowy-derive",
"flowy-document-pub", "flowy-document-pub",
@ -1910,7 +1904,6 @@ dependencies = [
"indexmap 2.1.0", "indexmap 2.1.0",
"lib-dispatch", "lib-dispatch",
"lib-infra", "lib-infra",
"lru",
"nanoid", "nanoid",
"parking_lot 0.12.1", "parking_lot 0.12.1",
"protobuf", "protobuf",
@ -2472,7 +2465,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue" name = "gotrue"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"futures-util", "futures-util",
@ -2489,7 +2482,7 @@ dependencies = [
[[package]] [[package]]
name = "gotrue-entity" name = "gotrue-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -2560,10 +2553,6 @@ name = "hashbrown"
version = "0.14.3" version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
dependencies = [
"ahash 0.8.6",
"allocator-api2",
]
[[package]] [[package]]
name = "hdrhistogram" name = "hdrhistogram"
@ -2883,7 +2872,7 @@ dependencies = [
[[package]] [[package]]
name = "infra" name = "infra"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"reqwest", "reqwest",
@ -3120,15 +3109,6 @@ version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "lru"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1efa59af2ddfad1854ae27d75009d538d0998b4b2fd47083e743ac1a10e46c60"
dependencies = [
"hashbrown 0.14.3",
]
[[package]] [[package]]
name = "mac" name = "mac"
version = "0.1.1" version = "0.1.1"
@ -4945,7 +4925,7 @@ dependencies = [
[[package]] [[package]]
name = "shared-entity" name = "shared-entity"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"app-error", "app-error",
@ -6358,7 +6338,7 @@ dependencies = [
[[package]] [[package]]
name = "workspace-template" name = "workspace-template"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=d77fb77a3a1df1dec14db68bebe35d911d9ae437#d77fb77a3a1df1dec14db68bebe35d911d9ae437" source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=0821c052f996b56ec42b86c9462f065e4639d735#0821c052f996b56ec42b86c9462f065e4639d735"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",

View File

@ -74,7 +74,6 @@ tokio = "1.34.0"
tokio-stream = "0.1.14" tokio-stream = "0.1.14"
async-trait = "0.1.74" async-trait = "0.1.74"
chrono = { version = "0.4.31", default-features = false, features = ["clock"] } chrono = { version = "0.4.31", default-features = false, features = ["clock"] }
lru = "0.12.0"
[profile.dev] [profile.dev]
opt-level = 0 opt-level = 0
@ -110,7 +109,7 @@ rocksdb = { git = "https://github.com/LucasXu0/rust-rocksdb", rev = "21cf4a23ec1
# Run the script: # Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id # scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "d77fb77a3a1df1dec14db68bebe35d911d9ae437" } client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "0821c052f996b56ec42b86c9462f065e4639d735" }
# Please use the following script to update collab. # Please use the following script to update collab.
# Working directory: frontend # Working directory: frontend
# #
@ -120,10 +119,10 @@ client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "d77
# To switch to the local path, run: # To switch to the local path, run:
# scripts/tool/update_collab_source.sh # scripts/tool/update_collab_source.sh
# ⚠️⚠️⚠️️ # ⚠️⚠️⚠️️
collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-plugins = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }
collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "c08d23f5a1f9f0de9465a3b248aedeaf8cd65381" } collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "ab468ea96a15863d1e792ea4bed3a8769f3ea8a7" }

View File

@ -21,7 +21,7 @@ use collab_plugins::local_storage::CollabPersistenceConfig;
use lib_infra::{if_native, if_wasm}; use lib_infra::{if_native, if_wasm};
use parking_lot::{Mutex, RwLock}; use parking_lot::{Mutex, RwLock};
use tracing::trace; use tracing::{error, trace};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum CollabPluginProviderType { pub enum CollabPluginProviderType {
@ -208,33 +208,49 @@ impl AppFlowyCollabBuilder {
#[allow(unused_variables)] persistence_config: CollabPersistenceConfig, #[allow(unused_variables)] persistence_config: CollabPersistenceConfig,
build_config: CollabBuilderConfig, build_config: CollabBuilderConfig,
) -> Result<Arc<MutexCollab>, Error> { ) -> Result<Arc<MutexCollab>, Error> {
let mut builder = CollabBuilder::new(uid, object_id) let is_from_doc_state = matches!(collab_doc_state, DocStateSource::FromDocState(_));
let collab = CollabBuilder::new(uid, object_id)
.with_doc_state(collab_doc_state) .with_doc_state(collab_doc_state)
.with_device_id(self.device_id.clone()); .with_device_id(self.device_id.clone())
.build()?;
// If the object is from doc state, we need to validate the object type
if is_from_doc_state {
if let Err(err) = object_type.validate(&collab.lock()) {
error!(
"{:?} validation failed: {}, object_id: {}",
object_type, err, object_id
);
return Err(err);
}
}
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
{ {
builder = builder.with_plugin(IndexeddbDiskPlugin::new( collab.lock().add_plugin(Box::new(IndexeddbDiskPlugin::new(
uid, uid,
object_id.to_string(), object_id.to_string(),
object_type.clone(), object_type.clone(),
collab_db.clone(), collab_db.clone(),
)); )));
} }
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
{ {
builder = builder.with_plugin(RocksdbDiskPlugin::new_with_config( collab
uid, .lock()
object_id.to_string(), .add_plugin(Box::new(RocksdbDiskPlugin::new_with_config(
object_type.clone(), uid,
collab_db.clone(), object_id.to_string(),
persistence_config.clone(), object_type.clone(),
None, collab_db.clone(),
)); persistence_config.clone(),
None,
)));
} }
let collab = Arc::new(builder.build()?); let arc_collab = Arc::new(collab);
{ {
let collab_object = self.collab_object(uid, object_id, object_type)?; let collab_object = self.collab_object(uid, object_id, object_type)?;
if build_config.sync_enable { if build_config.sync_enable {
@ -244,7 +260,7 @@ impl AppFlowyCollabBuilder {
match provider_type { match provider_type {
CollabPluginProviderType::AppFlowyCloud => { CollabPluginProviderType::AppFlowyCloud => {
trace!("init appflowy cloud collab plugins"); trace!("init appflowy cloud collab plugins");
let local_collab = Arc::downgrade(&collab); let local_collab = Arc::downgrade(&arc_collab);
let plugins = let plugins =
self self
.plugin_provider .plugin_provider
@ -257,14 +273,14 @@ impl AppFlowyCollabBuilder {
trace!("add appflowy cloud collab plugins: {}", plugins.len()); trace!("add appflowy cloud collab plugins: {}", plugins.len());
for plugin in plugins { for plugin in plugins {
collab.lock().add_plugin(plugin); arc_collab.lock().add_plugin(plugin);
} }
}, },
CollabPluginProviderType::Supabase => { CollabPluginProviderType::Supabase => {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
{ {
trace!("init supabase collab plugins"); trace!("init supabase collab plugins");
let local_collab = Arc::downgrade(&collab); let local_collab = Arc::downgrade(&arc_collab);
let local_collab_db = collab_db.clone(); let local_collab_db = collab_db.clone();
let plugins = let plugins =
self self
@ -277,7 +293,7 @@ impl AppFlowyCollabBuilder {
local_collab_db, local_collab_db,
}); });
for plugin in plugins { for plugin in plugins {
collab.lock().add_plugin(plugin); arc_collab.lock().add_plugin(plugin);
} }
} }
}, },
@ -287,12 +303,12 @@ impl AppFlowyCollabBuilder {
} }
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
futures::executor::block_on(collab.lock().initialize()); futures::executor::block_on(arc_collab.lock().initialize());
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
collab.lock().initialize(); arc_collab.lock().initialize();
trace!("collab initialized: {}", object_id); trace!("collab initialized: {}", object_id);
Ok(collab) Ok(arc_collab)
} }
} }

View File

@ -73,6 +73,7 @@ impl FlowySupabaseDatabaseTest {
.get_database_object_doc_state(database_id, CollabType::Database, &workspace_id) .get_database_object_doc_state(database_id, CollabType::Database, &workspace_id)
.await .await
.unwrap() .unwrap()
.unwrap()
} }
} }

View File

@ -126,6 +126,15 @@ impl FolderOperationHandler for DocumentFolderOperation {
}) })
} }
fn open_view(&self, view_id: &str) -> FutureResult<(), FlowyError> {
let manager = self.0.clone();
let view_id = view_id.to_string();
FutureResult::new(async move {
manager.open_document(&view_id).await?;
Ok(())
})
}
/// Close the document view. /// Close the document view.
fn close_view(&self, view_id: &str) -> FutureResult<(), FlowyError> { fn close_view(&self, view_id: &str) -> FutureResult<(), FlowyError> {
let manager = self.0.clone(); let manager = self.0.clone();
@ -236,6 +245,15 @@ impl FolderOperationHandler for DocumentFolderOperation {
struct DatabaseFolderOperation(Arc<DatabaseManager>); struct DatabaseFolderOperation(Arc<DatabaseManager>);
impl FolderOperationHandler for DatabaseFolderOperation { impl FolderOperationHandler for DatabaseFolderOperation {
fn open_view(&self, view_id: &str) -> FutureResult<(), FlowyError> {
let database_manager = self.0.clone();
let view_id = view_id.to_string();
FutureResult::new(async move {
database_manager.open_database_view(view_id).await?;
Ok(())
})
}
fn close_view(&self, view_id: &str) -> FutureResult<(), FlowyError> { fn close_view(&self, view_id: &str) -> FutureResult<(), FlowyError> {
let database_manager = self.0.clone(); let database_manager = self.0.clone();
let view_id = view_id.to_string(); let view_id = view_id.to_string();

View File

@ -4,6 +4,10 @@ use crate::AppFlowyCoreConfig;
static INIT_LOG: AtomicBool = AtomicBool::new(false); static INIT_LOG: AtomicBool = AtomicBool::new(false);
pub(crate) fn init_log(config: &AppFlowyCoreConfig) { pub(crate) fn init_log(config: &AppFlowyCoreConfig) {
if cfg!(debug_assertions) && get_bool_from_env_var("DISABLE_CI_TEST_LOG") {
return;
}
if !INIT_LOG.load(Ordering::SeqCst) { if !INIT_LOG.load(Ordering::SeqCst) {
INIT_LOG.store(true, Ordering::SeqCst); INIT_LOG.store(true, Ordering::SeqCst);
@ -12,6 +16,7 @@ pub(crate) fn init_log(config: &AppFlowyCoreConfig) {
.build(); .build();
} }
} }
pub(crate) fn create_log_filter(level: String, with_crates: Vec<String>) -> String { pub(crate) fn create_log_filter(level: String, with_crates: Vec<String>) -> String {
let level = std::env::var("RUST_LOG").unwrap_or(level); let level = std::env::var("RUST_LOG").unwrap_or(level);
let mut filters = with_crates let mut filters = with_crates
@ -49,3 +54,15 @@ pub(crate) fn create_log_filter(level: String, with_crates: Vec<String>) -> Stri
filters.join(",") filters.join(",")
} }
#[cfg(debug_assertions)]
fn get_bool_from_env_var(env_var_name: &str) -> bool {
match std::env::var(env_var_name) {
Ok(value) => match value.to_lowercase().as_str() {
"true" | "1" => true,
"false" | "0" => false,
_ => false,
},
Err(_) => false,
}
}

View File

@ -225,7 +225,7 @@ impl DatabaseCloudService for ServerProvider {
object_id: &str, object_id: &str,
collab_type: CollabType, collab_type: CollabType,
workspace_id: &str, workspace_id: &str,
) -> FutureResult<Vec<u8>, Error> { ) -> FutureResult<Option<Vec<u8>>, Error> {
let workspace_id = workspace_id.to_string(); let workspace_id = workspace_id.to_string();
let server = self.get_server(); let server = self.get_server();
let database_id = object_id.to_string(); let database_id = object_id.to_string();

View File

@ -9,13 +9,16 @@ pub type CollabDocStateByOid = HashMap<String, DocStateSource>;
/// A trait for database cloud service. /// A trait for database cloud service.
/// Each kind of server should implement this trait. Check out the [AppFlowyServerProvider] of /// Each kind of server should implement this trait. Check out the [AppFlowyServerProvider] of
/// [flowy-server] crate for more information. /// [flowy-server] crate for more information.
///
/// returns the doc state of the object with the given object_id.
/// None if the object is not found.
pub trait DatabaseCloudService: Send + Sync { pub trait DatabaseCloudService: Send + Sync {
fn get_database_object_doc_state( fn get_database_object_doc_state(
&self, &self,
object_id: &str, object_id: &str,
collab_type: CollabType, collab_type: CollabType,
workspace_id: &str, workspace_id: &str,
) -> FutureResult<Vec<u8>, Error>; ) -> FutureResult<Option<Vec<u8>>, Error>;
fn batch_get_database_object_doc_state( fn batch_get_database_object_doc_state(
&self, &self,

View File

@ -47,7 +47,6 @@ chrono-tz = "0.8.2"
csv = "1.1.6" csv = "1.1.6"
strum = "0.25" strum = "0.25"
strum_macros = "0.25" strum_macros = "0.25"
lru.workspace = true
validator = { version = "0.16.0", features = ["derive"] } validator = { version = "0.16.0", features = ["derive"] }
[dev-dependencies] [dev-dependencies]

View File

@ -14,7 +14,7 @@ pub fn init(database_manager: Weak<DatabaseManager>) -> AFPlugin {
.state(database_manager); .state(database_manager);
plugin plugin
.event(DatabaseEvent::GetDatabase, get_database_data_handler) .event(DatabaseEvent::GetDatabase, get_database_data_handler)
.event(DatabaseEvent::OpenDatabase, get_database_data_handler) .event(DatabaseEvent::GetDatabaseData, get_database_data_handler)
.event(DatabaseEvent::GetDatabaseId, get_database_id_handler) .event(DatabaseEvent::GetDatabaseId, get_database_id_handler)
.event(DatabaseEvent::GetDatabaseSetting, get_database_setting_handler) .event(DatabaseEvent::GetDatabaseSetting, get_database_setting_handler)
.event(DatabaseEvent::UpdateDatabaseSetting, update_database_setting_handler) .event(DatabaseEvent::UpdateDatabaseSetting, update_database_setting_handler)
@ -128,7 +128,7 @@ pub enum DatabaseEvent {
DeleteAllSorts = 6, DeleteAllSorts = 6,
#[event(input = "DatabaseViewIdPB")] #[event(input = "DatabaseViewIdPB")]
OpenDatabase = 7, GetDatabaseData = 7,
/// [GetFields] event is used to get the database's fields. /// [GetFields] event is used to get the database's fields.
/// ///

View File

@ -1,19 +1,17 @@
use anyhow::anyhow;
use std::collections::HashMap; use std::collections::HashMap;
use std::num::NonZeroUsize;
use std::sync::{Arc, Weak}; use std::sync::{Arc, Weak};
use collab::core::collab::{DocStateSource, MutexCollab}; use collab::core::collab::{DocStateSource, MutexCollab};
use collab_database::blocks::BlockEvent; use collab_database::blocks::BlockEvent;
use collab_database::database::{get_inline_view_id, DatabaseData, MutexDatabase}; use collab_database::database::{DatabaseData, MutexDatabase};
use collab_database::error::DatabaseError; use collab_database::error::DatabaseError;
use collab_database::user::{ use collab_database::views::{CreateDatabaseParams, CreateViewParams, DatabaseLayout};
use collab_database::workspace_database::{
CollabDocStateByOid, CollabFuture, DatabaseCollabService, DatabaseMeta, WorkspaceDatabase, CollabDocStateByOid, CollabFuture, DatabaseCollabService, DatabaseMeta, WorkspaceDatabase,
}; };
use collab_database::views::{CreateDatabaseParams, CreateViewParams, DatabaseLayout};
use collab_entity::CollabType; use collab_entity::CollabType;
use collab_plugins::local_storage::kv::KVTransactionDB; use collab_plugins::local_storage::kv::KVTransactionDB;
use lru::LruCache;
use tokio::sync::{Mutex, RwLock}; use tokio::sync::{Mutex, RwLock};
use tracing::{event, instrument, trace}; use tracing::{event, instrument, trace};
@ -40,7 +38,7 @@ pub struct DatabaseManager {
user: Arc<dyn DatabaseUser>, user: Arc<dyn DatabaseUser>,
workspace_database: Arc<RwLock<Option<Arc<WorkspaceDatabase>>>>, workspace_database: Arc<RwLock<Option<Arc<WorkspaceDatabase>>>>,
task_scheduler: Arc<RwLock<TaskDispatcher>>, task_scheduler: Arc<RwLock<TaskDispatcher>>,
editors: Mutex<LruCache<String, Arc<DatabaseEditor>>>, editors: Mutex<HashMap<String, Arc<DatabaseEditor>>>,
collab_builder: Arc<AppFlowyCollabBuilder>, collab_builder: Arc<AppFlowyCollabBuilder>,
cloud_service: Arc<dyn DatabaseCloudService>, cloud_service: Arc<dyn DatabaseCloudService>,
} }
@ -52,12 +50,11 @@ impl DatabaseManager {
collab_builder: Arc<AppFlowyCollabBuilder>, collab_builder: Arc<AppFlowyCollabBuilder>,
cloud_service: Arc<dyn DatabaseCloudService>, cloud_service: Arc<dyn DatabaseCloudService>,
) -> Self { ) -> Self {
let editors = Mutex::new(LruCache::new(NonZeroUsize::new(5).unwrap()));
Self { Self {
user: database_user, user: database_user,
workspace_database: Default::default(), workspace_database: Default::default(),
task_scheduler, task_scheduler,
editors, editors: Default::default(),
collab_builder, collab_builder,
cloud_service, cloud_service,
} }
@ -84,7 +81,7 @@ impl DatabaseManager {
self.task_scheduler.write().await.clear_task(); self.task_scheduler.write().await.clear_task();
// 2. Release all existing editors // 2. Release all existing editors
for (_, editor) in self.editors.lock().await.iter() { for (_, editor) in self.editors.lock().await.iter() {
editor.close().await; editor.close_all_views().await;
} }
self.editors.lock().await.clear(); self.editors.lock().await.clear();
// 3. Clear the workspace database // 3. Clear the workspace database
@ -111,8 +108,13 @@ impl DatabaseManager {
) )
.await .await
{ {
Ok(doc_state) => { Ok(doc_state) => match doc_state {
workspace_database_doc_state = DocStateSource::FromDocState(doc_state); Some(doc_state) => {
workspace_database_doc_state = DocStateSource::FromDocState(doc_state);
},
None => {
workspace_database_doc_state = DocStateSource::FromDisk;
},
}, },
Err(err) => { Err(err) => {
return Err(FlowyError::record_not_found().with_context(format!( return Err(FlowyError::record_not_found().with_context(format!(
@ -136,7 +138,7 @@ impl DatabaseManager {
collab_db.clone(), collab_db.clone(),
workspace_database_doc_state, workspace_database_doc_state,
config.clone(), config.clone(),
); )?;
let workspace_database = let workspace_database =
WorkspaceDatabase::open(uid, collab, collab_db, config, collab_builder); WorkspaceDatabase::open(uid, collab, collab_db, config, collab_builder);
*self.workspace_database.write().await = Some(Arc::new(workspace_database)); *self.workspace_database.write().await = Some(Arc::new(workspace_database));
@ -163,17 +165,12 @@ impl DatabaseManager {
pub async fn get_database_inline_view_id(&self, database_id: &str) -> FlowyResult<String> { pub async fn get_database_inline_view_id(&self, database_id: &str) -> FlowyResult<String> {
let wdb = self.get_workspace_database().await?; let wdb = self.get_workspace_database().await?;
let database_collab = wdb.get_database_collab(database_id).await.ok_or_else(|| { let database_collab = wdb.get_database(database_id).await.ok_or_else(|| {
FlowyError::record_not_found().with_context(format!("The database:{} not found", database_id)) FlowyError::record_not_found().with_context(format!("The database:{} not found", database_id))
})?; })?;
let inline_view_id = get_inline_view_id(&database_collab.lock()).ok_or_else(|| { let lock_guard = database_collab.lock();
FlowyError::record_not_found().with_context(format!( Ok(lock_guard.get_inline_view_id())
"Can't find the inline view for database:{}",
database_id
))
})?;
Ok(inline_view_id)
} }
pub async fn get_all_databases_meta(&self) -> Vec<DatabaseMeta> { pub async fn get_all_databases_meta(&self) -> Vec<DatabaseMeta> {
@ -218,7 +215,7 @@ impl DatabaseManager {
} }
pub async fn open_database(&self, database_id: &str) -> FlowyResult<Arc<DatabaseEditor>> { pub async fn open_database(&self, database_id: &str) -> FlowyResult<Arc<DatabaseEditor>> {
trace!("create new editor for database {}", database_id); trace!("open database editor:{}", database_id);
let database = self let database = self
.get_workspace_database() .get_workspace_database()
.await? .await?
@ -234,18 +231,35 @@ impl DatabaseManager {
.editors .editors
.lock() .lock()
.await .await
.put(database_id.to_string(), editor.clone()); .insert(database_id.to_string(), editor.clone());
Ok(editor) Ok(editor)
} }
pub async fn open_database_view<T: AsRef<str>>(&self, view_id: T) -> FlowyResult<()> {
let view_id = view_id.as_ref();
let wdb = self.get_workspace_database().await?;
if let Some(database_id) = wdb.get_database_id_with_view_id(view_id) {
wdb.open_database(&database_id);
}
Ok(())
}
pub async fn close_database_view<T: AsRef<str>>(&self, view_id: T) -> FlowyResult<()> { pub async fn close_database_view<T: AsRef<str>>(&self, view_id: T) -> FlowyResult<()> {
let view_id = view_id.as_ref(); let view_id = view_id.as_ref();
let wdb = self.get_workspace_database().await?; let wdb = self.get_workspace_database().await?;
let database_id = wdb.get_database_id_with_view_id(view_id); let database_id = wdb.get_database_id_with_view_id(view_id);
if let Some(database_id) = database_id { if let Some(database_id) = database_id {
let mut editors = self.editors.lock().await; let mut editors = self.editors.lock().await;
let mut should_remove = false;
if let Some(editor) = editors.get(&database_id) { if let Some(editor) = editors.get(&database_id) {
editor.close_view(view_id).await; editor.close_view(view_id).await;
should_remove = editor.num_views().await == 0;
}
if should_remove {
trace!("remove database editor:{}", database_id);
editors.remove(&database_id);
wdb.close_database(&database_id);
} }
} }
@ -428,15 +442,15 @@ impl DatabaseCollabService for UserDatabaseCollabServiceImpl {
let weak_cloud_service = Arc::downgrade(&self.cloud_service); let weak_cloud_service = Arc::downgrade(&self.cloud_service);
Box::pin(async move { Box::pin(async move {
match weak_cloud_service.upgrade() { match weak_cloud_service.upgrade() {
None => { None => Err(DatabaseError::Internal(anyhow!("Cloud service is dropped"))),
tracing::warn!("Cloud service is dropped");
Ok(DocStateSource::FromDocState(vec![]))
},
Some(cloud_service) => { Some(cloud_service) => {
let doc_state = cloud_service let doc_state = cloud_service
.get_database_object_doc_state(&object_id, object_ty, &workspace_id) .get_database_object_doc_state(&object_id, object_ty, &workspace_id)
.await?; .await?;
Ok(DocStateSource::FromDocState(doc_state)) match doc_state {
None => Ok(DocStateSource::FromDisk),
Some(doc_state) => Ok(DocStateSource::FromDocState(doc_state)),
}
}, },
} }
}) })
@ -473,18 +487,16 @@ impl DatabaseCollabService for UserDatabaseCollabServiceImpl {
collab_db: Weak<CollabKVDB>, collab_db: Weak<CollabKVDB>,
collab_raw_data: DocStateSource, collab_raw_data: DocStateSource,
persistence_config: CollabPersistenceConfig, persistence_config: CollabPersistenceConfig,
) -> Arc<MutexCollab> { ) -> Result<Arc<MutexCollab>, DatabaseError> {
self let collab = self.collab_builder.build_with_config(
.collab_builder uid,
.build_with_config( object_id,
uid, object_type.clone(),
object_id, collab_db.clone(),
object_type, collab_raw_data,
collab_db, persistence_config,
collab_raw_data, CollabBuilderConfig::default().sync_enable(true),
persistence_config, )?;
CollabBuilderConfig::default().sync_enable(true), Ok(collab)
)
.unwrap()
} }
} }

View File

@ -1,22 +1,3 @@
use std::collections::HashMap;
use std::sync::Arc;
use collab_database::database::MutexDatabase;
use collab_database::fields::{Field, TypeOptionData};
use collab_database::rows::{Cell, Cells, Row, RowCell, RowDetail, RowId};
use collab_database::views::{
DatabaseLayout, DatabaseView, FilterMap, LayoutSetting, OrderObjectPosition,
};
use futures::StreamExt;
use lib_infra::box_any::BoxAny;
use tokio::sync::{broadcast, RwLock};
use tracing::{event, warn};
use flowy_error::{internal_error, ErrorCode, FlowyError, FlowyResult};
use lib_dispatch::prelude::af_spawn;
use lib_infra::future::{to_fut, Fut, FutureResult};
use lib_infra::priority_task::TaskDispatcher;
use crate::entities::*; use crate::entities::*;
use crate::notification::{send_notification, DatabaseNotification}; use crate::notification::{send_notification, DatabaseNotification};
use crate::services::calculations::Calculation; use crate::services::calculations::Calculation;
@ -39,6 +20,22 @@ use crate::services::group::{default_group_setting, GroupChangeset, GroupSetting
use crate::services::share::csv::{CSVExport, CSVFormat}; use crate::services::share::csv::{CSVExport, CSVFormat};
use crate::services::sort::Sort; use crate::services::sort::Sort;
use crate::utils::cache::AnyTypeCache; use crate::utils::cache::AnyTypeCache;
use collab_database::database::MutexDatabase;
use collab_database::fields::{Field, TypeOptionData};
use collab_database::rows::{Cell, Cells, Row, RowCell, RowDetail, RowId};
use collab_database::views::{
DatabaseLayout, DatabaseView, FilterMap, LayoutSetting, OrderObjectPosition,
};
use flowy_error::{internal_error, ErrorCode, FlowyError, FlowyResult};
use futures::StreamExt;
use lib_dispatch::prelude::af_spawn;
use lib_infra::box_any::BoxAny;
use lib_infra::future::{to_fut, Fut, FutureResult};
use lib_infra::priority_task::TaskDispatcher;
use std::collections::HashMap;
use std::sync::Arc;
use tokio::sync::{broadcast, RwLock};
use tracing::{event, warn};
#[derive(Clone)] #[derive(Clone)]
pub struct DatabaseEditor { pub struct DatabaseEditor {
@ -115,23 +112,16 @@ impl DatabaseEditor {
}) })
} }
/// Returns bool value indicating whether the database is empty. pub async fn close_view(&self, view_id: &str) {
/// self.database_views.close_view(view_id).await;
pub async fn close_view(&self, view_id: &str) -> bool { }
// If the database is empty, flush the database to the disk.
if self.database_views.editors().await.len() == 1 { pub async fn num_views(&self) -> usize {
if let Some(database) = self.database.try_lock() { self.database_views.num_editors().await
let _ = database.flush();
}
}
self.database_views.close_view(view_id).await
} }
#[tracing::instrument(level = "debug", skip_all)] #[tracing::instrument(level = "debug", skip_all)]
pub async fn close(&self) { pub async fn close_all_views(&self) {
if let Some(database) = self.database.try_lock() {
let _ = database.flush();
}
for view in self.database_views.editors().await { for view in self.database_views.editors().await {
view.close().await; view.close().await;
} }

View File

@ -20,7 +20,7 @@ pub struct DatabaseViews {
database: Arc<MutexDatabase>, database: Arc<MutexDatabase>,
cell_cache: CellCache, cell_cache: CellCache,
view_operation: Arc<dyn DatabaseViewOperation>, view_operation: Arc<dyn DatabaseViewOperation>,
editor_by_view_id: Arc<RwLock<EditorByViewId>>, view_editors: Arc<RwLock<EditorByViewId>>,
} }
impl DatabaseViews { impl DatabaseViews {
@ -28,41 +28,38 @@ impl DatabaseViews {
database: Arc<MutexDatabase>, database: Arc<MutexDatabase>,
cell_cache: CellCache, cell_cache: CellCache,
view_operation: Arc<dyn DatabaseViewOperation>, view_operation: Arc<dyn DatabaseViewOperation>,
editor_by_view_id: Arc<RwLock<EditorByViewId>>, view_editors: Arc<RwLock<EditorByViewId>>,
) -> FlowyResult<Self> { ) -> FlowyResult<Self> {
Ok(Self { Ok(Self {
database, database,
view_operation, view_operation,
cell_cache, cell_cache,
editor_by_view_id, view_editors,
}) })
} }
pub async fn close_view(&self, view_id: &str) -> bool { pub async fn close_view(&self, view_id: &str) {
let mut editor_map = self.editor_by_view_id.write().await; let mut lock_guard = self.view_editors.write().await;
if let Some(view) = editor_map.remove(view_id) { if let Some(view) = lock_guard.remove(view_id) {
view.close().await; view.close().await;
} }
editor_map.is_empty() }
pub async fn num_editors(&self) -> usize {
self.view_editors.read().await.len()
} }
pub async fn editors(&self) -> Vec<Arc<DatabaseViewEditor>> { pub async fn editors(&self) -> Vec<Arc<DatabaseViewEditor>> {
self self.view_editors.read().await.values().cloned().collect()
.editor_by_view_id
.read()
.await
.values()
.cloned()
.collect()
} }
pub async fn get_view_editor(&self, view_id: &str) -> FlowyResult<Arc<DatabaseViewEditor>> { pub async fn get_view_editor(&self, view_id: &str) -> FlowyResult<Arc<DatabaseViewEditor>> {
debug_assert!(!view_id.is_empty()); debug_assert!(!view_id.is_empty());
if let Some(editor) = self.editor_by_view_id.read().await.get(view_id) { if let Some(editor) = self.view_editors.read().await.get(view_id) {
return Ok(editor.clone()); return Ok(editor.clone());
} }
let mut editor_map = self.editor_by_view_id.try_write().map_err(|err| { let mut editor_map = self.view_editors.try_write().map_err(|err| {
FlowyError::internal().with_context(format!( FlowyError::internal().with_context(format!(
"fail to acquire the lock of editor_by_view_id: {}", "fail to acquire the lock of editor_by_view_id: {}",
err err

View File

@ -35,8 +35,8 @@ indexmap = {version = "2.1.0", features = ["serde"]}
uuid.workspace = true uuid.workspace = true
futures.workspace = true futures.workspace = true
tokio-stream = { workspace = true, features = ["sync"] } tokio-stream = { workspace = true, features = ["sync"] }
dashmap = "5"
scraper = "0.18.0" scraper = "0.18.0"
lru.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies] [target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["js"]} getrandom = { version = "0.2", features = ["js"]}

View File

@ -1,21 +1,18 @@
use std::{
ops::{Deref, DerefMut},
sync::Arc,
};
use collab::core::collab::MutexCollab;
use collab_document::{blocks::DocumentData, document::Document};
use futures::StreamExt;
use parking_lot::Mutex;
use flowy_error::FlowyResult;
use lib_dispatch::prelude::af_spawn;
use tracing::trace;
use crate::entities::{ use crate::entities::{
DocEventPB, DocumentAwarenessStatesPB, DocumentSnapshotStatePB, DocumentSyncStatePB, DocEventPB, DocumentAwarenessStatesPB, DocumentSnapshotStatePB, DocumentSyncStatePB,
}; };
use crate::notification::{send_notification, DocumentNotification}; use crate::notification::{send_notification, DocumentNotification};
use collab::core::collab::MutexCollab;
use collab_document::{blocks::DocumentData, document::Document};
use flowy_error::FlowyResult;
use futures::StreamExt;
use lib_dispatch::prelude::af_spawn;
use parking_lot::Mutex;
use std::{
ops::{Deref, DerefMut},
sync::Arc,
};
use tracing::trace;
/// This struct wrap the document::Document /// This struct wrap the document::Document
#[derive(Clone)] #[derive(Clone)]

View File

@ -1,4 +1,3 @@
use std::num::NonZeroUsize;
use std::sync::Arc; use std::sync::Arc;
use std::sync::Weak; use std::sync::Weak;
@ -13,10 +12,9 @@ use collab_document::document_awareness::DocumentAwarenessUser;
use collab_document::document_data::default_document_data; use collab_document::document_data::default_document_data;
use collab_entity::CollabType; use collab_entity::CollabType;
use collab_plugins::CollabKVDB; use collab_plugins::CollabKVDB;
use dashmap::DashMap;
use flowy_storage::object_from_disk; use flowy_storage::object_from_disk;
use lib_infra::util::timestamp; use lib_infra::util::timestamp;
use lru::LruCache;
use parking_lot::Mutex;
use tokio::io::AsyncWriteExt; use tokio::io::AsyncWriteExt;
use tracing::{error, trace}; use tracing::{error, trace};
use tracing::{event, instrument}; use tracing::{event, instrument};
@ -53,7 +51,8 @@ pub trait DocumentSnapshotService: Send + Sync {
pub struct DocumentManager { pub struct DocumentManager {
pub user_service: Arc<dyn DocumentUserService>, pub user_service: Arc<dyn DocumentUserService>,
collab_builder: Arc<AppFlowyCollabBuilder>, collab_builder: Arc<AppFlowyCollabBuilder>,
documents: Arc<Mutex<LruCache<String, Arc<MutexDocument>>>>, documents: Arc<DashMap<String, Arc<MutexDocument>>>,
removing_documents: Arc<DashMap<String, Arc<MutexDocument>>>,
cloud_service: Arc<dyn DocumentCloudService>, cloud_service: Arc<dyn DocumentCloudService>,
storage_service: Weak<dyn ObjectStorageService>, storage_service: Weak<dyn ObjectStorageService>,
snapshot_service: Arc<dyn DocumentSnapshotService>, snapshot_service: Arc<dyn DocumentSnapshotService>,
@ -67,11 +66,11 @@ impl DocumentManager {
storage_service: Weak<dyn ObjectStorageService>, storage_service: Weak<dyn ObjectStorageService>,
snapshot_service: Arc<dyn DocumentSnapshotService>, snapshot_service: Arc<dyn DocumentSnapshotService>,
) -> Self { ) -> Self {
let documents = Arc::new(Mutex::new(LruCache::new(NonZeroUsize::new(10).unwrap())));
Self { Self {
user_service, user_service,
collab_builder, collab_builder,
documents, documents: Arc::new(Default::default()),
removing_documents: Arc::new(Default::default()),
cloud_service, cloud_service,
storage_service, storage_service,
snapshot_service, snapshot_service,
@ -79,7 +78,7 @@ impl DocumentManager {
} }
pub async fn initialize(&self, _uid: i64, _workspace_id: String) -> FlowyResult<()> { pub async fn initialize(&self, _uid: i64, _workspace_id: String) -> FlowyResult<()> {
self.documents.lock().clear(); self.documents.clear();
Ok(()) Ok(())
} }
@ -137,7 +136,11 @@ impl DocumentManager {
/// If the document exists, open the document and cache it /// If the document exists, open the document and cache it
#[tracing::instrument(level = "info", skip(self), err)] #[tracing::instrument(level = "info", skip(self), err)]
pub async fn get_document(&self, doc_id: &str) -> FlowyResult<Arc<MutexDocument>> { pub async fn get_document(&self, doc_id: &str) -> FlowyResult<Arc<MutexDocument>> {
if let Some(doc) = self.documents.lock().get(doc_id).cloned() { if let Some(doc) = self.documents.get(doc_id).map(|item| item.value().clone()) {
return Ok(doc);
}
if let Some(doc) = self.restore_document_from_removing(doc_id) {
return Ok(doc); return Ok(doc);
} }
@ -170,10 +173,7 @@ impl DocumentManager {
match MutexDocument::open(doc_id, collab) { match MutexDocument::open(doc_id, collab) {
Ok(document) => { Ok(document) => {
let document = Arc::new(document); let document = Arc::new(document);
self self.documents.insert(doc_id.to_string(), document.clone());
.documents
.lock()
.put(doc_id.to_string(), document.clone());
Ok(document) Ok(document)
}, },
Err(err) => { Err(err) => {
@ -188,31 +188,50 @@ impl DocumentManager {
} }
pub async fn get_document_data(&self, doc_id: &str) -> FlowyResult<DocumentData> { pub async fn get_document_data(&self, doc_id: &str) -> FlowyResult<DocumentData> {
let mut doc_state = vec![]; let mut doc_state = DocStateSource::FromDisk;
if !self.is_doc_exist(doc_id).await? { if !self.is_doc_exist(doc_id).await? {
doc_state = self doc_state = DocStateSource::FromDocState(
.cloud_service self
.get_document_doc_state(doc_id, &self.user_service.workspace_id()?) .cloud_service
.await?; .get_document_doc_state(doc_id, &self.user_service.workspace_id()?)
.await?,
);
} }
let uid = self.user_service.user_id()?; let uid = self.user_service.user_id()?;
let collab = self let collab = self
.collab_for_document(uid, doc_id, DocStateSource::FromDocState(doc_state), false) .collab_for_document(uid, doc_id, doc_state, false)
.await?; .await?;
Document::open(collab)? Document::open(collab)?
.get_document_data() .get_document_data()
.map_err(internal_error) .map_err(internal_error)
} }
pub async fn open_document(&self, doc_id: &str) -> FlowyResult<()> {
// TODO(nathan): refactor the get_database that split the database creation and database opening.
self.restore_document_from_removing(doc_id);
Ok(())
}
pub async fn close_document(&self, doc_id: &str) -> FlowyResult<()> { pub async fn close_document(&self, doc_id: &str) -> FlowyResult<()> {
// The lru will pop the least recently used document when the cache is full. if let Some((doc_id, document)) = self.documents.remove(doc_id) {
if let Ok(doc) = self.get_document(doc_id).await { if let Some(doc) = document.try_lock() {
trace!("close document: {}", doc_id);
if let Some(doc) = doc.try_lock() {
// clear the awareness state when close the document // clear the awareness state when close the document
doc.clean_awareness_local_state(); doc.clean_awareness_local_state();
let _ = doc.flush(); let _ = doc.flush();
} }
let clone_doc_id = doc_id.clone();
trace!("move document to removing_documents: {}", doc_id);
self.removing_documents.insert(doc_id, document);
let weak_removing_documents = Arc::downgrade(&self.removing_documents);
af_spawn(async move {
tokio::time::sleep(std::time::Duration::from_secs(120)).await;
if let Some(removing_documents) = weak_removing_documents.upgrade() {
if removing_documents.remove(&clone_doc_id).is_some() {
trace!("drop document from removing_documents: {}", clone_doc_id);
}
}
});
} }
Ok(()) Ok(())
@ -222,9 +241,8 @@ impl DocumentManager {
let uid = self.user_service.user_id()?; let uid = self.user_service.user_id()?;
if let Some(db) = self.user_service.collab_db(uid)?.upgrade() { if let Some(db) = self.user_service.collab_db(uid)?.upgrade() {
db.delete_doc(uid, doc_id).await?; db.delete_doc(uid, doc_id).await?;
// When deleting a document, we need to remove it from the cache. // When deleting a document, we need to remove it from the cache.
self.documents.lock().pop(doc_id); self.documents.remove(doc_id);
} }
Ok(()) Ok(())
} }
@ -401,6 +419,16 @@ impl DocumentManager {
pub fn get_file_storage_service(&self) -> &Weak<dyn ObjectStorageService> { pub fn get_file_storage_service(&self) -> &Weak<dyn ObjectStorageService> {
&self.storage_service &self.storage_service
} }
fn restore_document_from_removing(&self, doc_id: &str) -> Option<Arc<MutexDocument>> {
let (doc_id, doc) = self.removing_documents.remove(doc_id)?;
trace!(
"move document {} from removing_documents to documents",
doc_id
);
self.documents.insert(doc_id, doc.clone());
Some(doc)
}
} }
async fn doc_state_from_document_data( async fn doc_state_from_document_data(

View File

@ -205,7 +205,7 @@ impl FolderManager {
workspace_id, workspace_id,
CollabType::Folder, CollabType::Folder,
collab_db, collab_db,
DocStateSource::FromDocState(vec![]), DocStateSource::FromDisk,
CollabPersistenceConfig::new() CollabPersistenceConfig::new()
.enable_snapshot(true) .enable_snapshot(true)
.snapshot_per_update(50), .snapshot_per_update(50),
@ -782,7 +782,15 @@ impl FolderManager {
}, },
)?; )?;
send_workspace_setting_notification(workspace_id, self.get_current_view().await); let view = self.get_current_view().await;
if let Some(view) = &view {
let view_layout: ViewLayout = view.layout.clone().into();
if let Some(handle) = self.operation_handlers.get(&view_layout) {
let _ = handle.open_view(view_id).await;
}
}
send_workspace_setting_notification(workspace_id, view);
Ok(()) Ok(())
} }

View File

@ -211,7 +211,6 @@ pub(crate) fn notify_did_update_section_views(workspace_id: &str, folder: &Folde
pub(crate) fn notify_did_update_workspace(workspace_id: &str, folder: &Folder) { pub(crate) fn notify_did_update_workspace(workspace_id: &str, folder: &Folder) {
let repeated_view: RepeatedViewPB = get_workspace_public_view_pbs(workspace_id, folder).into(); let repeated_view: RepeatedViewPB = get_workspace_public_view_pbs(workspace_id, folder).into();
tracing::trace!("Did update workspace views: {:?}", repeated_view);
send_notification(workspace_id, FolderNotification::DidUpdateWorkspaceViews) send_notification(workspace_id, FolderNotification::DidUpdateWorkspaceViews)
.payload(repeated_view) .payload(repeated_view)
.send(); .send();

View File

@ -32,6 +32,7 @@ pub trait FolderOperationHandler {
FutureResult::new(async { Ok(()) }) FutureResult::new(async { Ok(()) })
} }
fn open_view(&self, view_id: &str) -> FutureResult<(), FlowyError>;
/// Closes the view and releases the resources that this view has in /// Closes the view and releases the resources that this view has in
/// the backend /// the backend
fn close_view(&self, view_id: &str) -> FutureResult<(), FlowyError>; fn close_view(&self, view_id: &str) -> FutureResult<(), FlowyError>;

View File

@ -45,11 +45,20 @@ mime_guess = "2.0"
url = "2.4" url = "2.4"
tokio-util = "0.7" tokio-util = "0.7"
tokio-stream = { workspace = true, features = ["sync"] } tokio-stream = { workspace = true, features = ["sync"] }
client-api = { version = "0.1.0", features = ["collab-sync", "test_util"] }
lib-dispatch = { workspace = true } lib-dispatch = { workspace = true }
yrs = "0.17.1" yrs = "0.17.1"
rand = "0.8.5" rand = "0.8.5"
[dependencies.client-api]
version = "0.1.0"
features = [
"collab-sync",
"test_util",
# Uncomment the following line to enable verbose logging for sync
# "sync_verbose_log",
]
[dev-dependencies] [dev-dependencies]
uuid.workspace = true uuid.workspace = true
tracing-subscriber = { version = "0.3.3", features = ["env-filter"] } tracing-subscriber = { version = "0.3.3", features = ["env-filter"] }

View File

@ -23,7 +23,7 @@ where
object_id: &str, object_id: &str,
collab_type: CollabType, collab_type: CollabType,
workspace_id: &str, workspace_id: &str,
) -> FutureResult<Vec<u8>, Error> { ) -> FutureResult<Option<Vec<u8>>, Error> {
let workspace_id = workspace_id.to_string(); let workspace_id = workspace_id.to_string();
let object_id = object_id.to_string(); let object_id = object_id.to_string();
let try_get_client = self.0.try_get_client(); let try_get_client = self.0.try_get_client();
@ -36,10 +36,10 @@ where
}, },
}; };
match try_get_client?.get_collab(params).await { match try_get_client?.get_collab(params).await {
Ok(data) => Ok(data.doc_state.to_vec()), Ok(data) => Ok(Some(data.doc_state.to_vec())),
Err(err) => { Err(err) => {
if err.code == RecordNotFound { if err.code == RecordNotFound {
Ok(vec![]) Ok(None)
} else { } else {
Err(Error::new(err)) Err(Error::new(err))
} }

View File

@ -1,5 +1,8 @@
use anyhow::Error; use anyhow::Error;
use collab::preclude::Collab;
use collab_entity::define::{DATABASE, DATABASE_ROW_DATA, WORKSPACE_DATABASES};
use collab_entity::CollabType; use collab_entity::CollabType;
use yrs::{Any, MapPrelim};
use flowy_database_pub::cloud::{CollabDocStateByOid, DatabaseCloudService, DatabaseSnapshot}; use flowy_database_pub::cloud::{CollabDocStateByOid, DatabaseCloudService, DatabaseSnapshot};
use lib_infra::future::FutureResult; use lib_infra::future::FutureResult;
@ -9,11 +12,40 @@ pub(crate) struct LocalServerDatabaseCloudServiceImpl();
impl DatabaseCloudService for LocalServerDatabaseCloudServiceImpl { impl DatabaseCloudService for LocalServerDatabaseCloudServiceImpl {
fn get_database_object_doc_state( fn get_database_object_doc_state(
&self, &self,
_object_id: &str, object_id: &str,
_collab_type: CollabType, collab_type: CollabType,
_workspace_id: &str, _workspace_id: &str,
) -> FutureResult<Vec<u8>, Error> { ) -> FutureResult<Option<Vec<u8>>, Error> {
FutureResult::new(async move { Ok(vec![]) }) let object_id = object_id.to_string();
// create the minimal required data for the given collab type
FutureResult::new(async move {
let data = match collab_type {
CollabType::Database => {
let collab = Collab::new(1, object_id, collab_type, vec![], false);
collab.with_origin_transact_mut(|txn| {
collab.insert_map_with_txn(txn, DATABASE);
});
collab.encode_collab_v1().doc_state.to_vec()
},
CollabType::WorkspaceDatabase => {
let collab = Collab::new(1, object_id, collab_type, vec![], false);
collab.with_origin_transact_mut(|txn| {
collab.create_array_with_txn::<MapPrelim<Any>>(txn, WORKSPACE_DATABASES, vec![]);
});
collab.encode_collab_v1().doc_state.to_vec()
},
CollabType::DatabaseRow => {
let collab = Collab::new(1, object_id, collab_type, vec![], false);
collab.with_origin_transact_mut(|txn| {
collab.insert_map_with_txn(txn, DATABASE_ROW_DATA);
});
collab.encode_collab_v1().doc_state.to_vec()
},
_ => vec![],
};
Ok(Some(data))
})
} }
fn batch_get_database_object_doc_state( fn batch_get_database_object_doc_state(

View File

@ -30,7 +30,7 @@ where
object_id: &str, object_id: &str,
collab_type: CollabType, collab_type: CollabType,
_workspace_id: &str, _workspace_id: &str,
) -> FutureResult<Vec<u8>, Error> { ) -> FutureResult<Option<Vec<u8>>, Error> {
let try_get_postgrest = self.server.try_get_weak_postgrest(); let try_get_postgrest = self.server.try_get_weak_postgrest();
let object_id = object_id.to_string(); let object_id = object_id.to_string();
let (tx, rx) = channel(); let (tx, rx) = channel();
@ -41,7 +41,7 @@ where
let updates = FetchObjectUpdateAction::new(object_id.to_string(), collab_type, postgrest) let updates = FetchObjectUpdateAction::new(object_id.to_string(), collab_type, postgrest)
.run_with_fix_interval(5, 10) .run_with_fix_interval(5, 10)
.await?; .await?;
Ok(updates) Ok(Some(updates))
} }
.await, .await,
) )

View File

@ -284,7 +284,7 @@ pub async fn batch_get_updates_from_server(
match parser_updates_form_json(record.clone(), &postgrest.secret()) { match parser_updates_form_json(record.clone(), &postgrest.secret()) {
Ok(items) => { Ok(items) => {
if items.is_empty() { if items.is_empty() {
updates_by_oid.insert(oid.to_string(), DocStateSource::FromDocState(vec![])); updates_by_oid.insert(oid.to_string(), DocStateSource::FromDisk);
} else { } else {
let updates = items let updates = items
.iter() .iter()

View File

@ -10,7 +10,7 @@ use collab_database::database::{
is_database_collab, mut_database_views_with_collab, reset_inline_view_id, is_database_collab, mut_database_views_with_collab, reset_inline_view_id,
}; };
use collab_database::rows::{database_row_document_id_from_row_id, mut_row_with_collab, RowId}; use collab_database::rows::{database_row_document_id_from_row_id, mut_row_with_collab, RowId};
use collab_database::user::DatabaseMetaList; use collab_database::workspace_database::DatabaseMetaList;
use collab_folder::{Folder, UserId}; use collab_folder::{Folder, UserId};
use collab_plugins::local_storage::kv::KVTransactionDB; use collab_plugins::local_storage::kv::KVTransactionDB;
use parking_lot::{Mutex, RwLock}; use parking_lot::{Mutex, RwLock};

View File

@ -8,7 +8,7 @@ use collab::core::collab::MutexCollab;
use collab::preclude::Collab; use collab::preclude::Collab;
use collab_database::database::get_database_row_ids; use collab_database::database::get_database_row_ids;
use collab_database::rows::database_row_document_id_from_row_id; use collab_database::rows::database_row_document_id_from_row_id;
use collab_database::user::{get_all_database_meta, DatabaseMeta}; use collab_database::workspace_database::{get_all_database_meta, DatabaseMeta};
use collab_entity::{CollabObject, CollabType}; use collab_entity::{CollabObject, CollabType};
use collab_folder::{Folder, View, ViewLayout}; use collab_folder::{Folder, View, ViewLayout};
use collab_plugins::local_storage::kv::KVTransactionDB; use collab_plugins::local_storage::kv::KVTransactionDB;

View File

@ -14,7 +14,7 @@ use collab_database::database::{
is_database_collab, mut_database_views_with_collab, reset_inline_view_id, is_database_collab, mut_database_views_with_collab, reset_inline_view_id,
}; };
use collab_database::rows::{database_row_document_id_from_row_id, mut_row_with_collab, RowId}; use collab_database::rows::{database_row_document_id_from_row_id, mut_row_with_collab, RowId};
use collab_database::user::DatabaseMetaList; use collab_database::workspace_database::DatabaseMetaList;
use collab_document::document_data::default_document_collab_data; use collab_document::document_data::default_document_collab_data;
use collab_entity::CollabType; use collab_entity::CollabType;
use collab_folder::{Folder, UserId, View, ViewIdentifier, ViewLayout}; use collab_folder::{Folder, UserId, View, ViewIdentifier, ViewLayout};

View File

@ -77,7 +77,7 @@ env = { RUST_LOG = "info" }
description = "Run rust-lib unit tests" description = "Run rust-lib unit tests"
script = ''' script = '''
cd rust-lib cd rust-lib
RUST_LOG=info RUST_BACKTRACE=1 cargo test --no-default-features --features "rev-sqlite" RUST_LOG=info DISABLE_CI_TEST_LOG="true" RUST_BACKTRACE=1 cargo test --no-default-features --features "rev-sqlite"
''' '''