fix: ws connect with invalid token (#5282)

* chore: bump client api

* chore: fix potentail ws connect with invalid token

* fix: cargo clippy

---------

Co-authored-by: Lucas.Xu <lucas.xu@appflowy.io>
This commit is contained in:
Nathan.fooo 2024-05-07 17:37:11 +08:00 committed by GitHub
parent dc813d85a8
commit b4279f8004
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 152 additions and 117 deletions

View File

@ -162,7 +162,7 @@ checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]]
name = "app-error"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"bincode",
@ -739,8 +739,8 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"again",
"anyhow",
@ -786,7 +786,7 @@ dependencies = [
[[package]]
name = "client-websocket"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"futures-channel",
"futures-util",
@ -1025,7 +1025,7 @@ dependencies = [
[[package]]
name = "collab-rt-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"bincode",
@ -1050,7 +1050,7 @@ dependencies = [
[[package]]
name = "collab-rt-protocol"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"async-trait",
@ -1407,7 +1407,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]]
name = "database-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"app-error",
@ -2777,7 +2777,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"futures-util",
@ -2794,7 +2794,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"app-error",
@ -3226,7 +3226,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"reqwest",
@ -5714,7 +5714,7 @@ dependencies = [
[[package]]
name = "shared-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"app-error",

View File

@ -47,6 +47,13 @@ collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFl
collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "870cd70" }
collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "870cd70" }
# Please using the following command to update the revision id
# Current directory: frontend
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "ef8e6f3" }
[dependencies]
serde_json.workspace = true
serde.workspace = true
@ -95,11 +102,3 @@ default = ["custom-protocol"]
# this feature is used used for production builds where `devPath` points to the filesystem
# DO NOT remove this
custom-protocol = ["tauri/custom-protocol"]
[patch.crates-io]
# Please using the following command to update the revision id
# Current directory: frontend
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "47e6f1e8" }

View File

@ -216,7 +216,7 @@ checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]]
name = "app-error"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"bincode",
@ -547,8 +547,8 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"again",
"anyhow",
@ -594,7 +594,7 @@ dependencies = [
[[package]]
name = "client-websocket"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"futures-channel",
"futures-util",
@ -772,7 +772,7 @@ dependencies = [
[[package]]
name = "collab-rt-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"bincode",
@ -797,7 +797,7 @@ dependencies = [
[[package]]
name = "collab-rt-protocol"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"async-trait",
@ -1011,7 +1011,7 @@ checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5"
[[package]]
name = "database-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"app-error",
@ -1788,7 +1788,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"futures-util",
@ -1805,7 +1805,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"app-error",
@ -2106,7 +2106,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"reqwest",
@ -3732,7 +3732,7 @@ dependencies = [
[[package]]
name = "shared-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"app-error",

View File

@ -50,6 +50,13 @@ collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlo
collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "870cd70" }
yrs = "0.18.7"
# Please using the following command to update the revision id
# Current directory: frontend
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "ef8e6f3" }
[profile.dev]
@ -61,12 +68,3 @@ codegen-units = 16
lto = true
opt-level = 3
codegen-units = 1
[patch.crates-io]
# Please using the following command to update the revision id
# Current directory: frontend
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "47e6f1e8" }

View File

@ -153,7 +153,7 @@ checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247"
[[package]]
name = "app-error"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"bincode",
@ -713,8 +713,8 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"again",
"anyhow",
@ -760,7 +760,7 @@ dependencies = [
[[package]]
name = "client-websocket"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"futures-channel",
"futures-util",
@ -1008,7 +1008,7 @@ dependencies = [
[[package]]
name = "collab-rt-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"bincode",
@ -1033,7 +1033,7 @@ dependencies = [
[[package]]
name = "collab-rt-protocol"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"async-trait",
@ -1394,7 +1394,7 @@ checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5"
[[package]]
name = "database-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"app-error",
@ -2851,7 +2851,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"futures-util",
@ -2868,7 +2868,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"app-error",
@ -3305,7 +3305,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"reqwest",
@ -5809,7 +5809,7 @@ dependencies = [
[[package]]
name = "shared-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"app-error",

View File

@ -47,6 +47,13 @@ collab-database = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFl
collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "870cd70" }
collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "870cd70" }
# Please using the following command to update the revision id
# Current directory: frontend
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "ef8e6f3" }
[dependencies]
serde_json.workspace = true
serde.workspace = true
@ -95,10 +102,3 @@ default = ["custom-protocol"]
# DO NOT remove this
custom-protocol = ["tauri/custom-protocol"]
[patch.crates-io]
# Please using the following command to update the revision id
# Current directory: frontend
# Run the script:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "47e6f1e8" }

View File

@ -163,7 +163,7 @@ checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
[[package]]
name = "app-error"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"bincode",
@ -649,8 +649,8 @@ dependencies = [
[[package]]
name = "client-api"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
version = "0.2.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"again",
"anyhow",
@ -696,7 +696,7 @@ dependencies = [
[[package]]
name = "client-websocket"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"futures-channel",
"futures-util",
@ -904,7 +904,7 @@ dependencies = [
[[package]]
name = "collab-rt-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"bincode",
@ -929,7 +929,7 @@ dependencies = [
[[package]]
name = "collab-rt-protocol"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"async-trait",
@ -1149,7 +1149,7 @@ dependencies = [
"cssparser-macros",
"dtoa-short",
"itoa",
"phf 0.8.0",
"phf 0.11.2",
"smallvec",
]
@ -1248,7 +1248,7 @@ checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308"
[[package]]
name = "database-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"app-error",
@ -2461,7 +2461,7 @@ dependencies = [
[[package]]
name = "gotrue"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"futures-util",
@ -2478,7 +2478,7 @@ dependencies = [
[[package]]
name = "gotrue-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"app-error",
@ -2843,7 +2843,7 @@ dependencies = [
[[package]]
name = "infra"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"reqwest",
@ -3718,7 +3718,7 @@ version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dfb61232e34fcb633f43d12c58f83c1df82962dcdfa565a4e866ffc17dafe12"
dependencies = [
"phf_macros",
"phf_macros 0.8.0",
"phf_shared 0.8.0",
"proc-macro-hack",
]
@ -3738,6 +3738,7 @@ version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc"
dependencies = [
"phf_macros 0.11.2",
"phf_shared 0.11.2",
]
@ -3805,6 +3806,19 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "phf_macros"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b"
dependencies = [
"phf_generator 0.11.2",
"phf_shared 0.11.2",
"proc-macro2",
"quote",
"syn 2.0.47",
]
[[package]]
name = "phf_shared"
version = "0.8.0"
@ -4008,7 +4022,7 @@ checksum = "c55e02e35260070b6f716a2423c2ff1c3bb1642ddca6f99e1f26d06268a0e2d2"
dependencies = [
"bytes",
"heck 0.4.1",
"itertools 0.10.5",
"itertools 0.11.0",
"log",
"multimap",
"once_cell",
@ -4029,7 +4043,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e"
dependencies = [
"anyhow",
"itertools 0.10.5",
"itertools 0.11.0",
"proc-macro2",
"quote",
"syn 2.0.47",
@ -4926,7 +4940,7 @@ dependencies = [
[[package]]
name = "shared-entity"
version = "0.1.0"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=47e6f1e8#47e6f1e8b1d3d037401f094aa11459b6c75cfa1a"
source = "git+https://github.com/AppFlowy-IO/AppFlowy-Cloud?rev=ef8e6f3#ef8e6f360f9c1d4daf2283e8475894d2ca5ef2fc"
dependencies = [
"anyhow",
"app-error",

View File

@ -94,6 +94,13 @@ collab-plugins = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlo
collab-user = { version = "0.2", git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "870cd70" }
yrs = "0.18.7"
# Please using the following command to update the revision id
# Current directory: frontend
# Run the script.add_workspace_members:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
client-api = { git = "https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "ef8e6f3" }
[profile.dev]
opt-level = 1
lto = false
@ -122,10 +129,3 @@ incremental = false
# TODO(Lucas.Xu) Upgrade to the latest version of RocksDB once PR(https://github.com/rust-rocksdb/rust-rocksdb/pull/869) is merged.
# Currently, using the following revision id. This commit is patched to fix the 32-bit build issue and it's checked out from 0.21.0, not 0.22.0.
rocksdb = { git = "https://github.com/LucasXu0/rust-rocksdb", rev = "21cf4a23ec131b9d82dc94e178fe8efc0c147b09" }
# Please using the following command to update the revision id
# Current directory: frontend
# Run the script.add_workspace_members:
# scripts/tool/update_client_api_rev.sh new_rev_id
# ⚠️⚠️⚠️️
client-api = { git = " https://github.com/AppFlowy-IO/AppFlowy-Cloud", rev = "47e6f1e8" }

View File

@ -30,7 +30,7 @@ collab = { workspace = true }
diesel.workspace = true
uuid.workspace = true
flowy-storage = { workspace = true }
client-api = { version = "0.1.0" }
client-api.workspace = true
tracing.workspace = true
futures-core = { version = "0.3", default-features = false }

View File

@ -31,7 +31,7 @@ collab-database = { workspace = true, optional = true }
collab-document = { workspace = true, optional = true }
collab-plugins = { workspace = true, optional = true }
collab-folder = { workspace = true, optional = true }
client-api = { version = "0.1.0", optional = true }
client-api = { workspace = true, optional = true }
tantivy = { version = "0.21.1", optional = true }

View File

@ -49,9 +49,8 @@ lib-dispatch = { workspace = true }
yrs.workspace = true
rand = "0.8.5"
[dependencies.client-api]
version = "0.1.0"
workspace = true
features = [
"collab-sync",
"test_util",

View File

@ -12,8 +12,10 @@ use client_api::ws::{
use client_api::{Client, ClientConfiguration};
use flowy_storage::ObjectStorageService;
use rand::Rng;
use tokio::sync::watch;
use tokio::select;
use tokio::sync::{watch, Mutex};
use tokio_stream::wrappers::WatchStream;
use tokio_util::sync::CancellationToken;
use tracing::{error, event, info, warn};
use uuid::Uuid;
@ -74,11 +76,22 @@ impl AppFlowyCloudServer {
let enable_sync = Arc::new(AtomicBool::new(enable_sync));
let network_reachable = Arc::new(AtomicBool::new(true));
let ws_client = WSClient::new(WSClientConfig::default(), api_client.clone());
let ws_client = WSClient::new(
WSClientConfig::default(),
api_client.clone(),
api_client.clone(),
);
let ws_client = Arc::new(ws_client);
let api_client = Arc::new(api_client);
let ws_connect_cancellation_token = Arc::new(Mutex::new(CancellationToken::new()));
spawn_ws_conn(token_state_rx, &ws_client, &api_client, &enable_sync);
spawn_ws_conn(
token_state_rx,
&ws_client,
ws_connect_cancellation_token,
&api_client,
&enable_sync,
);
Self {
config,
client: api_client,
@ -241,12 +254,14 @@ impl AppFlowyServer for AppFlowyCloudServer {
fn spawn_ws_conn(
mut token_state_rx: TokenStateReceiver,
ws_client: &Arc<WSClient>,
conn_cancellation_token: Arc<Mutex<CancellationToken>>,
api_client: &Arc<Client>,
enable_sync: &Arc<AtomicBool>,
) {
let weak_ws_client = Arc::downgrade(ws_client);
let weak_api_client = Arc::downgrade(api_client);
let enable_sync = enable_sync.clone();
let cloned_conn_cancellation_token = conn_cancellation_token.clone();
af_spawn(async move {
if let Some(ws_client) = weak_ws_client.upgrade() {
@ -256,15 +271,16 @@ fn spawn_ws_conn(
match state {
ConnectState::PingTimeout | ConnectState::Lost => {
// Try to reconnect if the connection is timed out.
if let Some(api_client) = weak_api_client.upgrade() {
if enable_sync.load(Ordering::SeqCst) {
attempt_reconnect(&ws_client, &api_client, 2).await;
}
if weak_api_client.upgrade().is_some() && enable_sync.load(Ordering::SeqCst) {
attempt_reconnect(&ws_client, 2, &cloned_conn_cancellation_token).await;
}
},
ConnectState::Unauthorized => {
if let Some(api_client) = weak_api_client.upgrade() {
if let Err(err) = api_client.refresh_token().await {
if let Err(err) = api_client
.refresh_token("websocket connect unauthorized")
.await
{
error!("Failed to refresh token: {}", err);
}
}
@ -276,21 +292,13 @@ fn spawn_ws_conn(
});
let weak_ws_client = Arc::downgrade(ws_client);
let weak_api_client = Arc::downgrade(api_client);
af_spawn(async move {
while let Ok(token_state) = token_state_rx.recv().await {
info!("🟢token state: {:?}", token_state);
match token_state {
TokenState::Refresh => {
if let (Some(api_client), Some(ws_client)) =
(weak_api_client.upgrade(), weak_ws_client.upgrade())
{
match api_client.ws_connect_info().await {
Ok(conn_info) => {
let _ = ws_client.connect(api_client.ws_addr(), conn_info).await;
},
Err(err) => error!("Failed to get ws url: {}", err),
}
if let Some(ws_client) = weak_ws_client.upgrade() {
attempt_reconnect(&ws_client, 5, &conn_cancellation_token).await;
}
},
TokenState::Invalid => {
@ -304,26 +312,43 @@ fn spawn_ws_conn(
});
}
/// Attempts to reconnect a WebSocket client with a randomized delay to mitigate the thundering herd problem.
///
/// This function cancels any existing reconnection attempt, sets up a new cancellation token, and then
/// attempts to reconnect after a randomized delay. The delay is set between a specified minimum and
/// that minimum plus 10 seconds.
///
async fn attempt_reconnect(
ws_client: &Arc<WSClient>,
api_client: &Arc<Client>,
minimum_delay: u64,
minimum_delay_in_secs: u64,
conn_cancellation_token: &Arc<Mutex<CancellationToken>>,
) {
// Introduce randomness in the reconnection attempts to avoid thundering herd problem
let delay_seconds = rand::thread_rng().gen_range(minimum_delay..8);
tokio::time::sleep(Duration::from_secs(delay_seconds)).await;
event!(
tracing::Level::INFO,
"🟢 Attempting to reconnect websocket."
);
match api_client.ws_connect_info().await {
Ok(conn_info) => {
if let Err(e) = ws_client.connect(api_client.ws_addr(), conn_info).await {
error!("Failed to reconnect websocket: {}", e);
// Cancel the previous reconnection attempt
let mut cancel_token_lock = conn_cancellation_token.lock().await;
cancel_token_lock.cancel();
let new_cancel_token = CancellationToken::new();
*cancel_token_lock = new_cancel_token.clone();
drop(cancel_token_lock);
// randomness in the reconnection attempts to avoid thundering herd problem
let delay_seconds = rand::thread_rng().gen_range(minimum_delay_in_secs..10);
let ws_client = ws_client.clone();
tokio::spawn(async move {
select! {
_ = new_cancel_token.cancelled() => {
event!(
tracing::Level::TRACE,
"🟢websocket reconnection attempt cancelled."
);
},
_ = tokio::time::sleep(Duration::from_secs(delay_seconds)) => {
if let Err(e) = ws_client.connect().await {
error!("Failed to reconnect websocket: {}", e);
}
}
},
Err(err) => error!("Failed to get websocket URL: {}", err),
}
}
});
}
pub trait AFServer: Send + Sync + 'static {