fix: compile errors

This commit is contained in:
appflowy 2022-02-07 15:47:16 +08:00
parent 0c6903f793
commit 9f8e3b09c3
6 changed files with 90 additions and 44 deletions

View File

@ -51,6 +51,12 @@ version = "1.0.52"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3" checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3"
[[package]]
name = "arrayvec"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]] [[package]]
name = "async-stream" name = "async-stream"
version = "0.3.2" version = "0.3.2"
@ -284,6 +290,18 @@ dependencies = [
"owo-colors", "owo-colors",
] ]
[[package]]
name = "config"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b076e143e1d9538dde65da30f8481c2a6c44040edb8e02b9bf1351edb92ce3"
dependencies = [
"lazy_static",
"nom",
"serde",
"yaml-rust",
]
[[package]] [[package]]
name = "convert_case" name = "convert_case"
version = "0.4.0" version = "0.4.0"
@ -889,6 +907,7 @@ dependencies = [
"anyhow", "anyhow",
"async-stream", "async-stream",
"bytes", "bytes",
"config",
"dashmap", "dashmap",
"flowy-collaboration", "flowy-collaboration",
"flowy-derive", "flowy-derive",
@ -900,12 +919,18 @@ dependencies = [
"flowy-user-data-model", "flowy-user-data-model",
"futures-util", "futures-util",
"http-response", "http-response",
"hyper",
"lazy_static", "lazy_static",
"lib-dispatch", "lib-dispatch",
"lib-infra", "lib-infra",
"lib-ws", "lib-ws",
"log",
"parking_lot", "parking_lot",
"protobuf", "protobuf",
"reqwest",
"serde",
"serde-aux",
"serde_json",
"strum", "strum",
"strum_macros", "strum_macros",
"tokio", "tokio",
@ -1448,6 +1473,19 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lexical-core"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe"
dependencies = [
"arrayvec",
"bitflags",
"cfg-if",
"ryu",
"static_assertions",
]
[[package]] [[package]]
name = "lib-dispatch" name = "lib-dispatch"
version = "0.1.0" version = "0.1.0"
@ -1586,6 +1624,12 @@ dependencies = [
"vcpkg", "vcpkg",
] ]
[[package]]
name = "linked-hash-map"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3"
[[package]] [[package]]
name = "lock_api" name = "lock_api"
version = "0.4.5" version = "0.4.5"
@ -1717,6 +1761,17 @@ dependencies = [
"tempfile", "tempfile",
] ]
[[package]]
name = "nom"
version = "5.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af"
dependencies = [
"lexical-core",
"memchr",
"version_check",
]
[[package]] [[package]]
name = "ntapi" name = "ntapi"
version = "0.3.6" version = "0.3.6"
@ -2279,6 +2334,17 @@ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]]
name = "serde-aux"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "905f2fc9f3d1574e8b5923a58118240021f01d4e239673937ffb9f42707a4f22"
dependencies = [
"chrono",
"serde",
"serde_json",
]
[[package]] [[package]]
name = "serde_cbor" name = "serde_cbor"
version = "0.11.2" version = "0.11.2"
@ -2432,6 +2498,12 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.10.0" version = "0.10.0"
@ -3036,3 +3108,12 @@ checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69"
dependencies = [ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "yaml-rust"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
dependencies = [
"linked-hash-map",
]

View File

@ -30,6 +30,13 @@ dashmap = {version = "4.0"}
async-stream = "0.3.2" async-stream = "0.3.2"
futures-util = "0.3.15" futures-util = "0.3.15"
http-response = { git = "https://github.com/AppFlowy-IO/AppFlowy-Server", features = ["with_reqwest"]} http-response = { git = "https://github.com/AppFlowy-IO/AppFlowy-Server", features = ["with_reqwest"]}
serde-aux = "1.0.1"
reqwest = "0.11"
hyper = "0.14"
config = { version = "0.10.1", default-features = false, features = ["yaml"] }
log = "0.4.14"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
[features] [features]
http_server = [] http_server = []

View File

@ -1,7 +1,6 @@
use config::FileFormat; use config::FileFormat;
use serde_aux::field_attributes::deserialize_number_from_string; use serde_aux::field_attributes::deserialize_number_from_string;
use std::convert::{TryFrom, TryInto}; use std::convert::{TryFrom, TryInto};
pub const HOST: &str = "localhost:8000";
pub const HEADER_TOKEN: &str = "token"; pub const HEADER_TOKEN: &str = "token";
#[derive(serde::Deserialize, Clone, Debug)] #[derive(serde::Deserialize, Clone, Debug)]
@ -89,6 +88,7 @@ pub enum Environment {
} }
impl Environment { impl Environment {
#[allow(dead_code)]
pub fn as_str(&self) -> &'static str { pub fn as_str(&self) -> &'static str {
match self { match self {
Environment::Local => "local", Environment::Local => "local",

View File

@ -4,7 +4,6 @@ mod event;
mod handlers; mod handlers;
pub mod http_server; pub mod http_server;
pub mod local_server; pub mod local_server;
mod middleware;
pub mod module; pub mod module;
pub mod protobuf; pub mod protobuf;
mod request; mod request;

View File

@ -1,41 +0,0 @@
use crate::{request::ResponseMiddleware, response::FlowyResponse};
use lazy_static::lazy_static;
use std::sync::Arc;
use tokio::sync::broadcast;
lazy_static! {
pub static ref BACKEND_API_MIDDLEWARE: Arc<WorkspaceMiddleware> = Arc::new(WorkspaceMiddleware::new());
}
pub struct WorkspaceMiddleware {
invalid_token_sender: broadcast::Sender<String>,
}
impl WorkspaceMiddleware {
fn new() -> Self {
let (sender, _) = broadcast::channel(10);
WorkspaceMiddleware {
invalid_token_sender: sender,
}
}
pub fn invalid_token_subscribe(&self) -> broadcast::Receiver<String> {
self.invalid_token_sender.subscribe()
}
}
impl ResponseMiddleware for WorkspaceMiddleware {
fn receive_response(&self, token: &Option<String>, response: &FlowyResponse) {
if let Some(error) = &response.error {
if error.is_unauthorized() {
log::error!("user is unauthorized");
match token {
None => {}
Some(token) => match self.invalid_token_sender.send(token.clone()) {
Ok(_) => {}
Err(e) => log::error!("{:?}", e),
},
}
}
}
}
}

View File

@ -76,7 +76,7 @@ fn crate_log_filter(level: String) -> String {
filters.push(format!("lib_ot={}", level)); filters.push(format!("lib_ot={}", level));
filters.push(format!("lib_ws={}", level)); filters.push(format!("lib_ws={}", level));
filters.push(format!("lib_infra={}", level)); filters.push(format!("lib_infra={}", level));
filters.push(format!("flowy_sync={}", level)); filters.push(format!("flowy_sync={}", "info"));
filters.join(",") filters.join(",")
} }