Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
[rust]: rm flowy-net
appflowyf93f012bc8ae
diff --git a/backend/Cargo.toml b/backend/Cargo.tomlindex 7c36687bc5..ed9c378149 100644--- a/backend/Cargo.toml+++ b/backend/Cargo.toml@@ -65,7 +65,7 @@ flowy-workspace-infra = { path = "../rust-lib/flowy-workspace-infra" }flowy-document-infra = { path = "../rust-lib/flowy-document-infra" }lib-ws = { path = "../rust-lib/lib-ws" }lib-ot = { path = "../rust-lib/lib-ot" }-flowy-net = { path = "../rust-lib/flowy-net", features = ["http_server"] }+backend-service = { path = "../rust-lib/backend-service", features = ["http_server"] }ormx = { version = "0.7", features = ["postgres"]}[dependencies.sqlx]@@ -99,7 +99,6 @@ parking_lot = "0.11"once_cell = "1.7.2"linkify = "0.5.0"backend = { path = ".", features = ["flowy_test"]}-backend-api = { path = "../rust-lib/backend-api" }flowy-sdk = { path = "../rust-lib/flowy-sdk", features = ["http_server"] }flowy-user = { path = "../rust-lib/flowy-user", features = ["http_server"] }flowy-document = { path = "../rust-lib/flowy-document", features = ["flowy_test", "http_server"] }diff --git a/backend/src/entities/token.rs b/backend/src/entities/token.rsindex 25d37e0844..52cb545659 100644--- a/backend/src/entities/token.rs+++ b/backend/src/entities/token.rs@@ -1,7 +1,7 @@use crate::config::env::{domain, jwt_secret};+use backend_service::errors::ServerError;use chrono::{Duration, Local};use derive_more::{From, Into};-use flowy_net::errors::ServerError;use jsonwebtoken::{decode, encode, Algorithm, DecodingKey, EncodingKey, Header, Validation};use serde::{Deserialize, Serialize};@@ -76,7 +76,7 @@ impl Token {use crate::service::user::EXPIRED_DURATION_DAYS;use actix_web::{dev::Payload, FromRequest, HttpRequest};-use flowy_net::config::HEADER_TOKEN;+use backend_service::config::HEADER_TOKEN;use futures::future::{ready, Ready};impl FromRequest for Token {diff --git a/backend/src/middleware/auth_middleware.rs b/backend/src/middleware/auth_middleware.rsindex 6829a85b66..a23208dc81 100644--- a/backend/src/middleware/auth_middleware.rs+++ b/backend/src/middleware/auth_middleware.rs@@ -9,7 +9,7 @@ use actix_web::{use crate::config::IGNORE_ROUTES;use actix_web::{body::AnyBody, dev::MessageBody};-use flowy_net::{config::HEADER_TOKEN, errors::ServerError};+use backend_service::{config::HEADER_TOKEN, errors::ServerError};use futures::future::{ok, LocalBoxFuture, Ready};use std::{convert::TryInto,diff --git a/backend/src/service/app/app.rs b/backend/src/service/app/app.rsindex 81b1813f11..acc2355e95 100644--- a/backend/src/service/app/app.rs+++ b/backend/src/service/app/app.rs@@ -5,8 +5,8 @@ use crate::{};use crate::service::trash::read_trash_ids;+use backend_service::errors::{invalid_params, ServerError};use chrono::Utc;-use flowy_net::errors::{invalid_params, ServerError};use flowy_workspace_infra::{parser::{app::{AppDesc, AppName},diff --git a/backend/src/service/app/router.rs b/backend/src/service/app/router.rsindex a490804edc..f95539a5d9 100644--- a/backend/src/service/app/router.rs+++ b/backend/src/service/app/router.rs@@ -2,7 +2,7 @@ use actix_web::{web::{Data, Payload},HttpResponse,};-use flowy_net::errors::{invalid_params, ServerError};+use backend_service::errors::{invalid_params, ServerError};use flowy_workspace_infra::protobuf::{AppIdentifier, CreateAppParams, UpdateAppParams};use protobuf::Message;use sqlx::PgPool;@@ -16,7 +16,7 @@ use crate::service::{util::parse_from_payload,};use anyhow::Context;-use flowy_net::response::FlowyResponse;+use backend_service::response::FlowyResponse;use flowy_workspace_infra::parser::app::{AppDesc, AppName};pub async fn create_handler(diff --git a/backend/src/service/app/sql_builder.rs b/backend/src/service/app/sql_builder.rsindex 4556dafda1..a2faa6d227 100644--- a/backend/src/service/app/sql_builder.rs+++ b/backend/src/service/app/sql_builder.rs@@ -2,8 +2,8 @@ use crate::{entities::workspace::{AppTable, APP_TABLE},sqlx_ext::SqlBuilder,};+use backend_service::errors::{invalid_params, ServerError};use chrono::{DateTime, NaiveDateTime, Utc};-use flowy_net::errors::{invalid_params, ServerError};use flowy_workspace_infra::{parser::app::AppId,protobuf::{App, ColorStyle},diff --git a/backend/src/service/doc/crud.rs b/backend/src/service/doc/crud.rsindex ad504667ae..18377c71c7 100644--- a/backend/src/service/doc/crud.rs+++ b/backend/src/service/doc/crud.rs@@ -3,8 +3,8 @@ use crate::{sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},};use anyhow::Context;+use backend_service::errors::ServerError;use flowy_document_infra::protobuf::{CreateDocParams, Doc, DocIdentifier, UpdateDocParams};-use flowy_net::errors::ServerError;use sqlx::{postgres::PgArguments, PgPool, Postgres};use uuid::Uuid;diff --git a/backend/src/service/doc/doc.rs b/backend/src/service/doc/doc.rsindex 84cd3708b6..f1a0937d6e 100644--- a/backend/src/service/doc/doc.rs+++ b/backend/src/service/doc/doc.rs@@ -7,9 +7,9 @@ use crate::service::{ws::{WsBizHandler, WsClientData},};use actix_web::web::Data;+use backend_service::errors::{internal_error, ServerError};use dashmap::DashMap;use flowy_document_infra::protobuf::DocIdentifier;-use flowy_net::errors::{internal_error, ServerError};use sqlx::PgPool;use std::sync::Arc;use tokio::{diff --git a/backend/src/service/doc/edit/edit_actor.rs b/backend/src/service/doc/edit/edit_actor.rsindex 86f6197b39..bca1bf3696 100644--- a/backend/src/service/doc/edit/edit_actor.rs+++ b/backend/src/service/doc/edit/edit_actor.rs@@ -4,8 +4,8 @@ use crate::service::{};use actix_web::web::Data;use async_stream::stream;+use backend_service::errors::{internal_error, Result as DocResult, ServerError};use flowy_document_infra::protobuf::{Doc, Revision};-use flowy_net::errors::{internal_error, Result as DocResult, ServerError};use futures::stream::StreamExt;use sqlx::PgPool;use std::sync::{atomic::Ordering::SeqCst, Arc};diff --git a/backend/src/service/doc/edit/edit_doc.rs b/backend/src/service/doc/edit/edit_doc.rsindex aa0e12606f..61aaae5737 100644--- a/backend/src/service/doc/edit/edit_doc.rs+++ b/backend/src/service/doc/edit/edit_doc.rs@@ -4,13 +4,13 @@ use crate::service::{ws::{entities::Socket, WsMessageAdaptor},};use actix_web::web::Data;+use backend_service::errors::{internal_error, ServerError};use dashmap::DashMap;use flowy_document_infra::{core::Document,entities::ws::{WsDataType, WsDocumentData},protobuf::{Doc, RevId, RevType, Revision, RevisionRange, UpdateDocParams},};-use flowy_net::errors::{internal_error, ServerError};use lib_ot::core::{Delta, OperationTransformable};use parking_lot::RwLock;use protobuf::Message;diff --git a/backend/src/service/doc/edit/open_handle.rs b/backend/src/service/doc/edit/open_handle.rsindex b97d97d346..006811daee 100644--- a/backend/src/service/doc/edit/open_handle.rs+++ b/backend/src/service/doc/edit/open_handle.rs@@ -3,8 +3,8 @@ use crate::service::{ws::{entities::Socket, WsUser},};use actix_web::web::Data;+use backend_service::errors::{internal_error, Result as DocResult, ServerError};use flowy_document_infra::protobuf::{Doc, Revision};-use flowy_net::errors::{internal_error, Result as DocResult, ServerError};use sqlx::PgPool;use std::sync::Arc;use tokio::sync::{mpsc, oneshot};diff --git a/backend/src/service/doc/router.rs b/backend/src/service/doc/router.rsindex ce30e466b2..1bad2b3d7f 100644--- a/backend/src/service/doc/router.rs+++ b/backend/src/service/doc/router.rs@@ -7,8 +7,8 @@ use actix_web::{HttpResponse,};use anyhow::Context;+use backend_service::{errors::ServerError, response::FlowyResponse};use flowy_document_infra::protobuf::{CreateDocParams, DocIdentifier, UpdateDocParams};-use flowy_net::{errors::ServerError, response::FlowyResponse};use sqlx::PgPool;pub async fn create_handler(payload: Payload, pool: Data<PgPool>) -> Result<HttpResponse, ServerError> {diff --git a/backend/src/service/doc/ws_actor.rs b/backend/src/service/doc/ws_actor.rsindex 64f38f4582..ef18fc08c4 100644--- a/backend/src/service/doc/ws_actor.rs+++ b/backend/src/service/doc/ws_actor.rs@@ -6,8 +6,8 @@ use crate::service::{use actix_rt::task::spawn_blocking;use actix_web::web::Data;use async_stream::stream;+use backend_service::errors::{internal_error, Result as DocResult, ServerError};use flowy_document_infra::protobuf::{NewDocUser, Revision, WsDataType, WsDocumentData};-use flowy_net::errors::{internal_error, Result as DocResult, ServerError};use futures::stream::StreamExt;use sqlx::PgPool;use std::sync::Arc;diff --git a/backend/src/service/trash/router.rs b/backend/src/service/trash/router.rsindex fad8e053ba..cc267117a0 100644--- a/backend/src/service/trash/router.rs+++ b/backend/src/service/trash/router.rs@@ -9,7 +9,7 @@ use actix_web::{HttpResponse,};use anyhow::Context;-use flowy_net::{+use backend_service::{errors::{invalid_params, ServerError},response::FlowyResponse,};diff --git a/backend/src/service/trash/trash.rs b/backend/src/service/trash/trash.rsindex 165099262b..42b1e3d2b3 100644--- a/backend/src/service/trash/trash.rs+++ b/backend/src/service/trash/trash.rs@@ -8,7 +8,7 @@ use crate::{sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},};use ::protobuf::ProtobufEnum;-use flowy_net::errors::ServerError;+use backend_service::errors::ServerError;use flowy_workspace_infra::protobuf::{RepeatedTrash, Trash, TrashType};use sqlx::{postgres::PgArguments, Postgres, Row};use uuid::Uuid;diff --git a/backend/src/service/user/auth.rs b/backend/src/service/user/auth.rsindex aa5c332198..0dc32cf79b 100644--- a/backend/src/service/user/auth.rs+++ b/backend/src/service/user/auth.rs@@ -4,11 +4,11 @@ use crate::{sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},};use anyhow::Context;-use chrono::Utc;-use flowy_net::{+use backend_service::{errors::{invalid_params, ErrorCode, ServerError},response::FlowyResponse,};+use chrono::Utc;use flowy_user_infra::{parser::{UserEmail, UserName, UserPassword},protobuf::{SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserParams, UserProfile},diff --git a/backend/src/service/user/logged_user.rs b/backend/src/service/user/logged_user.rsindex 3cb65cea8d..cab12f2304 100644--- a/backend/src/service/user/logged_user.rs+++ b/backend/src/service/user/logged_user.rs@@ -1,8 +1,8 @@use crate::entities::token::{Claim, Token};use actix_web::http::HeaderValue;+use backend_service::errors::ServerError;use chrono::{DateTime, Utc};use dashmap::DashMap;-use flowy_net::errors::ServerError;use lazy_static::lazy_static;lazy_static! {diff --git a/backend/src/service/user/router.rs b/backend/src/service/user/router.rsindex 876be07539..53441d37c8 100644--- a/backend/src/service/user/router.rs+++ b/backend/src/service/user/router.rs@@ -6,7 +6,7 @@ use actix_web::{};use sqlx::PgPool;-use flowy_net::{errors::ServerError, response::FlowyResponse};+use backend_service::{errors::ServerError, response::FlowyResponse};use flowy_user_infra::protobuf::{SignInParams, SignUpParams, UpdateUserParams};use crate::{diff --git a/backend/src/service/user/user_default.rs b/backend/src/service/user/user_default.rsindex c18a76d9a4..56385c0d7e 100644--- a/backend/src/service/user/user_default.rs+++ b/backend/src/service/user/user_default.rs@@ -7,9 +7,9 @@ use crate::{};use crate::service::view::{create_view_with_args, sql_builder::NewViewSqlBuilder};+use backend_service::errors::ServerError;use chrono::Utc;use flowy_document_infra::user_default::doc_initial_string;-use flowy_net::errors::ServerError;use flowy_workspace_infra::protobuf::Workspace;use std::convert::TryInto;diff --git a/backend/src/service/user/utils.rs b/backend/src/service/user/utils.rsindex b2e9a76ab3..ed4428922b 100644--- a/backend/src/service/user/utils.rs+++ b/backend/src/service/user/utils.rs@@ -1,5 +1,5 @@+use backend_service::errors::{ErrorCode, ServerError};use bcrypt::{hash, verify, DEFAULT_COST};-use flowy_net::errors::{ErrorCode, ServerError};#[allow(dead_code)]pub fn uuid() -> String { uuid::Uuid::new_v4().to_string() }diff --git a/backend/src/service/util.rs b/backend/src/service/util.rsindex e5cca45657..327b43a3d6 100644--- a/backend/src/service/util.rs+++ b/backend/src/service/util.rs@@ -1,6 +1,6 @@use crate::config::MAX_PAYLOAD_SIZE;use actix_web::web;-use flowy_net::errors::{ErrorCode, ServerError};+use backend_service::errors::{ErrorCode, ServerError};use futures::StreamExt;use protobuf::{Message, ProtobufResult};@@ -10,9 +10,7 @@ pub async fn parse_from_payload<T: Message>(payload: web::Payload) -> Result<T,}#[allow(dead_code)]-pub async fn parse_from_dev_payload<T: Message>(- payload: &mut actix_web::dev::Payload,-) -> Result<T, ServerError> {+pub async fn parse_from_dev_payload<T: Message>(payload: &mut actix_web::dev::Payload) -> Result<T, ServerError> {let bytes = poll_payload(payload).await?;parse_from_bytes(&bytes)}@@ -31,9 +29,7 @@ pub fn parse_from_bytes<T: Message>(bytes: &[u8]) -> Result<T, ServerError> {}}-pub async fn poll_payload(- payload: &mut actix_web::dev::Payload,-) -> Result<web::BytesMut, ServerError> {+pub async fn poll_payload(payload: &mut actix_web::dev::Payload) -> Result<web::BytesMut, ServerError> {let mut body = web::BytesMut::new();while let Some(chunk) = payload.next().await {let chunk = chunk.map_err(|err| ServerError::internal().context(err))?;diff --git a/backend/src/service/view/router.rs b/backend/src/service/view/router.rsindex 7d3d856dce..5a6571e74f 100644--- a/backend/src/service/view/router.rs+++ b/backend/src/service/view/router.rs@@ -9,7 +9,7 @@ use actix_web::{HttpResponse,};use anyhow::Context;-use flowy_net::{+use backend_service::{errors::{invalid_params, ServerError},response::FlowyResponse,};diff --git a/backend/src/service/view/sql_builder.rs b/backend/src/service/view/sql_builder.rsindex 954b32d239..a8568b4edc 100644--- a/backend/src/service/view/sql_builder.rs+++ b/backend/src/service/view/sql_builder.rs@@ -2,8 +2,8 @@ use crate::{entities::workspace::{ViewTable, VIEW_TABLE},sqlx_ext::SqlBuilder,};+use backend_service::errors::{invalid_params, ServerError};use chrono::{DateTime, NaiveDateTime, Utc};-use flowy_net::errors::{invalid_params, ServerError};use flowy_workspace_infra::{parser::view::ViewId,protobuf::{View, ViewType},diff --git a/backend/src/service/view/view.rs b/backend/src/service/view/view.rsindex 0440c10fd8..0769a16f13 100644--- a/backend/src/service/view/view.rs+++ b/backend/src/service/view/view.rs@@ -8,9 +8,9 @@ use crate::{},sqlx_ext::{map_sqlx_error, DBTransaction, SqlBuilder},};+use backend_service::errors::{invalid_params, ServerError};use chrono::Utc;use flowy_document_infra::protobuf::CreateDocParams;-use flowy_net::errors::{invalid_params, ServerError};use flowy_workspace_infra::{parser::{app::AppId,diff --git a/backend/src/service/workspace/router.rs b/backend/src/service/workspace/router.rsindex bca7a4a6c4..47313059aa 100644--- a/backend/src/service/workspace/router.rs+++ b/backend/src/service/workspace/router.rs@@ -14,7 +14,7 @@ use actix_web::{HttpResponse,};use anyhow::Context;-use flowy_net::{+use backend_service::{errors::{invalid_params, ServerError},response::FlowyResponse,};diff --git a/backend/src/service/workspace/sql_builder.rs b/backend/src/service/workspace/sql_builder.rsindex 5c5c4850d0..42222c169b 100644--- a/backend/src/service/workspace/sql_builder.rs+++ b/backend/src/service/workspace/sql_builder.rs@@ -2,8 +2,8 @@ use crate::{entities::workspace::{WorkspaceTable, WORKSPACE_TABLE},sqlx_ext::SqlBuilder,};+use backend_service::errors::{invalid_params, ServerError};use chrono::{DateTime, NaiveDateTime, Utc};-use flowy_net::errors::{invalid_params, ServerError};use flowy_workspace_infra::{parser::workspace::WorkspaceId, protobuf::Workspace};use sqlx::postgres::PgArguments;use uuid::Uuid;diff --git a/backend/src/service/workspace/workspace.rs b/backend/src/service/workspace/workspace.rsindex 2bf801c96e..a6481ea24c 100644--- a/backend/src/service/workspace/workspace.rs+++ b/backend/src/service/workspace/workspace.rs@@ -5,7 +5,7 @@ use crate::{sqlx_ext::*,};use anyhow::Context;-use flowy_net::errors::{invalid_params, ServerError};+use backend_service::errors::{invalid_params, ServerError};use flowy_workspace_infra::{parser::workspace::WorkspaceId,protobuf::{RepeatedApp, RepeatedWorkspace, Workspace},diff --git a/backend/src/service/ws/entities/connect.rs b/backend/src/service/ws/entities/connect.rsindex c4c55b6cec..156b2c2b62 100644--- a/backend/src/service/ws/entities/connect.rs+++ b/backend/src/service/ws/entities/connect.rs@@ -1,6 +1,6 @@use crate::service::ws::WsMessageAdaptor;use actix::{Message, Recipient};-use flowy_net::errors::ServerError;+use backend_service::errors::ServerError;use serde::{Deserialize, Serialize};use std::fmt::Formatter;diff --git a/backend/src/service/ws/ws_server.rs b/backend/src/service/ws/ws_server.rsindex fca58def2f..d1a3751d2b 100644--- a/backend/src/service/ws/ws_server.rs+++ b/backend/src/service/ws/ws_server.rs@@ -3,8 +3,8 @@ use crate::service::ws::{WsMessageAdaptor,};use actix::{Actor, Context, Handler};+use backend_service::errors::ServerError;use dashmap::DashMap;-use flowy_net::errors::ServerError;pub struct WsServer {sessions: DashMap<SessionId, Session>,diff --git a/backend/src/sqlx_ext/query.rs b/backend/src/sqlx_ext/query.rsindex a0483aa62c..d9d7e1a6a3 100644--- a/backend/src/sqlx_ext/query.rs+++ b/backend/src/sqlx_ext/query.rs@@ -1,4 +1,4 @@-use flowy_net::errors::ServerError;+use backend_service::errors::ServerError;use sql_builder::SqlBuilder as InnerBuilder;use sqlx::{postgres::PgArguments, Arguments, Encode, Postgres, Type};diff --git a/backend/src/sqlx_ext/utils.rs b/backend/src/sqlx_ext/utils.rsindex bff0e0881f..0b0d69b6e4 100644--- a/backend/src/sqlx_ext/utils.rs+++ b/backend/src/sqlx_ext/utils.rs@@ -1,4 +1,4 @@-use flowy_net::errors::{ErrorCode, ServerError};+use backend_service::errors::{ErrorCode, ServerError};use sqlx::{Error, Postgres, Transaction};pub type DBTransaction<'a> = Transaction<'a, Postgres>;diff --git a/backend/tests/api/auth.rs b/backend/tests/api/auth.rsindex b4b68ceab0..a2772fff3d 100644--- a/backend/tests/api/auth.rs+++ b/backend/tests/api/auth.rs@@ -1,5 +1,5 @@use crate::util::helper::{spawn_user_server, TestUserServer};-use flowy_net::errors::ErrorCode;+use backend_service::errors::ErrorCode;use flowy_user_infra::entities::{SignInParams, SignUpParams, SignUpResponse, UpdateUserParams};#[actix_rt::test]diff --git a/backend/tests/document/helper.rs b/backend/tests/document/helper.rsindex be88f732b9..59716c1003 100644--- a/backend/tests/document/helper.rs+++ b/backend/tests/document/helper.rs@@ -1,7 +1,7 @@use actix_web::web::Data;use backend::service::doc::{crud::update_doc, doc::DocManager};+use backend_service::config::ServerConfig;use flowy_document::services::doc::ClientEditDoc as ClientEditDocContext;-use flowy_net::config::ServerConfig;use flowy_test::{workspace::ViewTest, FlowyTest};use flowy_user::services::user::UserSession;use futures_util::{stream, stream::StreamExt};diff --git a/backend/tests/util/helper.rs b/backend/tests/util/helper.rsindex 3e562def79..a592423ca6 100644--- a/backend/tests/util/helper.rs+++ b/backend/tests/util/helper.rs@@ -3,10 +3,9 @@ use backend::{config::{get_configuration, DatabaseSettings},context::AppContext,};-use backend_api::{user_request::*, workspace_request::*};+use backend_service::{errors::ServerError, user_request::*, workspace_request::*};use flowy_document::services::server::read_doc_request;use flowy_document_infra::entities::doc::{Doc, DocIdentifier};-use flowy_net::errors::ServerError;use flowy_user_infra::entities::*;use flowy_workspace_infra::entities::prelude::*;use sqlx::{Connection, Executor, PgConnection, PgPool};diff --git a/rust-lib/Cargo.toml b/rust-lib/Cargo.tomlindex 1a06df016a..40fe2cd676 100644--- a/rust-lib/Cargo.toml+++ b/rust-lib/Cargo.toml@@ -3,7 +3,7 @@ members = ["lib-dispatch","flowy-sdk","dart-ffi",- "lib-log",+ "lib-log","flowy-user","flowy-user-infra","flowy-ast",@@ -18,9 +18,8 @@ members = ["flowy-document","flowy-document-infra","lib-ot",- "flowy-net","lib-ws",- "backend-api",+ "backend-service",]exclude = ["../backend"]diff --git a/rust-lib/backend-api/Cargo.toml b/rust-lib/backend-api/Cargo.tomldeleted file mode 100644index 73992bd5b0..0000000000--- a/rust-lib/backend-api/Cargo.toml+++ /dev/null@@ -1,14 +0,0 @@-[package]-name = "backend-api"-version = "0.1.0"-edition = "2018"--# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html--[dependencies]-flowy-net = { path = "../flowy-net", features = ["flowy_request"] }-flowy-workspace-infra = { path = "../flowy-workspace-infra" }-flowy-user-infra = { path = "../flowy-user-infra" }-log = "0.4.14"-lazy_static = "1.4.0"-tokio = { version = "1", features = ["rt"] }\ No newline at end of filediff --git a/rust-lib/flowy-net/Cargo.toml b/rust-lib/backend-service/Cargo.tomlsimilarity index 68%rename from rust-lib/flowy-net/Cargo.tomlrename to rust-lib/backend-service/Cargo.tomlindex 94f828e0cb..d1af1429a8 100644--- a/rust-lib/flowy-net/Cargo.toml+++ b/rust-lib/backend-service/Cargo.toml@@ -1,32 +1,30 @@[package]-name = "flowy-net"+name = "backend-service"version = "0.1.0"edition = "2018"# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html[dependencies]+flowy-workspace-infra = { path = "../flowy-workspace-infra" }+flowy-user-infra = { path = "../flowy-user-infra" }++log = "0.4.14"+lazy_static = "1.4.0"+tokio = { version = "1", features = ["rt"] }+anyhow = "1.0"+thiserror = "1.0.24"+bytes = { version = "1.0", features = ["serde"]}reqwest = "0.11"hyper = "0.14"-protobuf = {version = "2.18.0"}serde = { version = "1.0", features = ["derive"] }serde_json = "1.0"serde_repr = "0.1"-pin-project = "1.0.0"-futures-core = { version = "0.3", default-features = false }-log = "0.4"+uuid = { version = "0.8", features = ["v4"] }+protobuf = {version = "2.18.0"}+derive_more = {version = "0.99", features = ["display"]}tracing = { version = "0.1", features = ["log"] }-bytes = { version = "1.0", features = ["serde"]}-lazy_static = "1.4.0"-tokio = { version = "1", features = ["full"] }actix-web = {version = "4.0.0-beta.8", optional = true}-derive_more = {version = "0.99", features = ["display"]}-flowy-derive = { path = "../flowy-derive" }-lib-infra = { path = "../lib-infra" }-anyhow = "1.0"-thiserror = "1.0.24"-uuid = { version = "0.8", features = ["v4"] }[features]-http_server = ["actix-web"]-flowy_request = []\ No newline at end of file+http_server = ["actix-web"]\ No newline at end of filediff --git a/rust-lib/flowy-net/src/config.rs b/rust-lib/backend-service/src/config.rssimilarity index 100%rename from rust-lib/flowy-net/src/config.rsrename to rust-lib/backend-service/src/config.rsdiff --git a/rust-lib/flowy-net/src/errors.rs b/rust-lib/backend-service/src/errors.rssimilarity index 100%rename from rust-lib/flowy-net/src/errors.rsrename to rust-lib/backend-service/src/errors.rsdiff --git a/rust-lib/backend-api/src/lib.rs b/rust-lib/backend-service/src/lib.rssimilarity index 50%rename from rust-lib/backend-api/src/lib.rsrename to rust-lib/backend-service/src/lib.rsindex cdd1c25f28..b4eeedc394 100644--- a/rust-lib/backend-api/src/lib.rs+++ b/rust-lib/backend-service/src/lib.rs@@ -1,3 +1,7 @@+pub mod config;+pub mod errors;pub mod middleware;+pub mod request;+pub mod response;pub mod user_request;pub mod workspace_request;diff --git a/rust-lib/backend-api/src/middleware.rs b/rust-lib/backend-service/src/middleware.rssimilarity index 94%rename from rust-lib/backend-api/src/middleware.rsrename to rust-lib/backend-service/src/middleware.rsindex a0a6233e7a..fee46765cc 100644--- a/rust-lib/backend-api/src/middleware.rs+++ b/rust-lib/backend-service/src/middleware.rs@@ -1,4 +1,4 @@-use flowy_net::{request::ResponseMiddleware, response::FlowyResponse};+use crate::{request::ResponseMiddleware, response::FlowyResponse};use lazy_static::lazy_static;use std::sync::Arc;use tokio::sync::broadcast;diff --git a/rust-lib/flowy-net/src/request/mod.rs b/rust-lib/backend-service/src/request/mod.rssimilarity index 100%rename from rust-lib/flowy-net/src/request/mod.rsrename to rust-lib/backend-service/src/request/mod.rsdiff --git a/rust-lib/flowy-net/src/request/request.rs b/rust-lib/backend-service/src/request/request.rssimilarity index 100%rename from rust-lib/flowy-net/src/request/request.rsrename to rust-lib/backend-service/src/request/request.rsdiff --git a/rust-lib/flowy-net/src/response/mod.rs b/rust-lib/backend-service/src/response/mod.rssimilarity index 81%rename from rust-lib/flowy-net/src/response/mod.rsrename to rust-lib/backend-service/src/response/mod.rsindex bc0828b6c7..9d6d60a6c6 100644--- a/rust-lib/flowy-net/src/response/mod.rs+++ b/rust-lib/backend-service/src/response/mod.rs@@ -1,5 +1,4 @@mod response;-mod response_serde;#[cfg(feature = "http_server")]mod response_http;diff --git a/rust-lib/flowy-net/src/response/response.rs b/rust-lib/backend-service/src/response/response.rssimilarity index 100%rename from rust-lib/flowy-net/src/response/response.rsrename to rust-lib/backend-service/src/response/response.rsdiff --git a/rust-lib/flowy-net/src/response/response_http.rs b/rust-lib/backend-service/src/response/response_http.rssimilarity index 100%rename from rust-lib/flowy-net/src/response/response_http.rsrename to rust-lib/backend-service/src/response/response_http.rsdiff --git a/rust-lib/backend-api/src/user_request.rs b/rust-lib/backend-service/src/user_request.rssimilarity index 90%rename from rust-lib/backend-api/src/user_request.rsrename to rust-lib/backend-service/src/user_request.rsindex da3f0e15fb..6a21f9ca15 100644--- a/rust-lib/backend-api/src/user_request.rs+++ b/rust-lib/backend-service/src/user_request.rs@@ -1,8 +1,8 @@-use flowy_net::{config::HEADER_TOKEN, errors::ServerError, request::HttpRequestBuilder};+use crate::{config::HEADER_TOKEN, errors::ServerError, request::HttpRequestBuilder};use flowy_user_infra::entities::prelude::*;pub(crate) fn request_builder() -> HttpRequestBuilder {- HttpRequestBuilder::new().middleware(super::middleware::BACKEND_API_MIDDLEWARE.clone())+ HttpRequestBuilder::new().middleware(crate::middleware::BACKEND_API_MIDDLEWARE.clone())}pub async fn user_sign_up_request(params: SignUpParams, url: &str) -> Result<SignUpResponse, ServerError> {diff --git a/rust-lib/backend-api/src/workspace_request.rs b/rust-lib/backend-service/src/workspace_request.rssimilarity index 96%rename from rust-lib/backend-api/src/workspace_request.rsrename to rust-lib/backend-service/src/workspace_request.rsindex 4fdc7d4e09..b621c88b9e 100644--- a/rust-lib/backend-api/src/workspace_request.rs+++ b/rust-lib/backend-service/src/workspace_request.rs@@ -1,8 +1,8 @@-use flowy_net::{config::HEADER_TOKEN, errors::ServerError, request::HttpRequestBuilder};+use crate::{config::HEADER_TOKEN, errors::ServerError, request::HttpRequestBuilder};use flowy_workspace_infra::entities::prelude::*;pub(crate) fn request_builder() -> HttpRequestBuilder {- HttpRequestBuilder::new().middleware(super::middleware::BACKEND_API_MIDDLEWARE.clone())+ HttpRequestBuilder::new().middleware(crate::middleware::BACKEND_API_MIDDLEWARE.clone())}pub async fn create_workspace_request(diff --git a/rust-lib/dart-ffi/Cargo.toml b/rust-lib/dart-ffi/Cargo.tomlindex c512c382d1..ecd83b239a 100644--- a/rust-lib/dart-ffi/Cargo.toml+++ b/rust-lib/dart-ffi/Cargo.toml@@ -28,7 +28,7 @@ lib-dispatch = {path = "../lib-dispatch" }flowy-sdk = {path = "../flowy-sdk"}flowy-derive = {path = "../flowy-derive"}dart-notify = {path = "../dart-notify" }-flowy-net = {path = "../flowy-net"}+backend-service = { path = "../backend-service" }[features]diff --git a/rust-lib/dart-ffi/src/lib.rs b/rust-lib/dart-ffi/src/lib.rsindex 226c07f731..b543f9f682 100644--- a/rust-lib/dart-ffi/src/lib.rs+++ b/rust-lib/dart-ffi/src/lib.rs@@ -69,7 +69,7 @@ pub extern "C" fn set_stream_port(port: i64) -> i32 {#[no_mangle]pub extern "C" fn link_me_please() {}-use flowy_net::config::ServerConfig;+use backend_service::config::ServerConfig;use lib_dispatch::prelude::ToBytes;#[inline(always)]diff --git a/rust-lib/flowy-document/Cargo.toml b/rust-lib/flowy-document/Cargo.tomlindex 1f5eecb124..07862cd19e 100644--- a/rust-lib/flowy-document/Cargo.toml+++ b/rust-lib/flowy-document/Cargo.toml@@ -16,7 +16,7 @@ lib-infra = { path = "../lib-infra" }dart-notify = { path = "../dart-notify" }lib-ot = { path = "../lib-ot" }lib-ws = { path = "../lib-ws" }-flowy-net = { path = "../flowy-net", features = ["flowy_request"] }+backend-service = { path = "../backend-service" }diesel = {version = "1.4.8", features = ["sqlite"]}diff --git a/rust-lib/flowy-document/src/errors.rs b/rust-lib/flowy-document/src/errors.rsindex e81683e39b..a737c44665 100644--- a/rust-lib/flowy-document/src/errors.rs+++ b/rust-lib/flowy-document/src/errors.rs@@ -1,7 +1,7 @@+use backend_service::errors::ServerError;use bytes::Bytes;use derive_more::Display;use flowy_derive::{ProtoBuf, ProtoBuf_Enum};-use flowy_net::errors::ServerError;use lib_dispatch::prelude::{EventResponse, ResponseBuilder};use std::{convert::TryInto, fmt};@@ -108,14 +108,14 @@ impl std::convert::From<protobuf::ProtobufError> for DocError {fn from(e: protobuf::ProtobufError) -> Self { DocError::internal().context(e) }}-impl std::convert::From<flowy_net::errors::ServerError> for DocError {+impl std::convert::From<backend_service::errors::ServerError> for DocError {fn from(error: ServerError) -> Self {let code = server_error_to_doc_error(error.code);DocError::new(code, &error.msg)}}-use flowy_net::errors::ErrorCode as ServerErrorCode;+use backend_service::errors::ErrorCode as ServerErrorCode;use std::fmt::Debug;fn server_error_to_doc_error(code: ServerErrorCode) -> ErrorCode {diff --git a/rust-lib/flowy-document/src/module.rs b/rust-lib/flowy-document/src/module.rsindex f098d66901..d0965b70dd 100644--- a/rust-lib/flowy-document/src/module.rs+++ b/rust-lib/flowy-document/src/module.rs@@ -6,9 +6,9 @@ use crate::{ws::WsDocumentManager,},};+use backend_service::config::ServerConfig;use flowy_database::ConnectionPool;use flowy_document_infra::entities::doc::{DocDelta, DocIdentifier};-use flowy_net::config::ServerConfig;use std::sync::Arc;pub trait DocumentUser: Send + Sync {diff --git a/rust-lib/flowy-document/src/services/server/middleware.rs b/rust-lib/flowy-document/src/services/server/middleware.rsindex 545cd8ddba..d4875c1c89 100644--- a/rust-lib/flowy-document/src/services/server/middleware.rs+++ b/rust-lib/flowy-document/src/services/server/middleware.rs@@ -1,4 +1,4 @@-use flowy_net::{request::ResponseMiddleware, response::FlowyResponse};+use backend_service::{request::ResponseMiddleware, response::FlowyResponse};use lazy_static::lazy_static;use std::sync::Arc;diff --git a/rust-lib/flowy-document/src/services/server/mod.rs b/rust-lib/flowy-document/src/services/server/mod.rsindex 3705fef28d..a51b4fcf2f 100644--- a/rust-lib/flowy-document/src/services/server/mod.rs+++ b/rust-lib/flowy-document/src/services/server/mod.rs@@ -5,8 +5,8 @@ mod server_api_mock;pub use server_api::*;// TODO: ignore mock files in productionuse crate::errors::DocError;+use backend_service::config::ServerConfig;use flowy_document_infra::entities::doc::{CreateDocParams, Doc, DocIdentifier, UpdateDocParams};-use flowy_net::config::ServerConfig;use lib_infra::future::ResultFuture;pub use server_api_mock::*;use std::sync::Arc;diff --git a/rust-lib/flowy-document/src/services/server/server_api.rs b/rust-lib/flowy-document/src/services/server/server_api.rsindex 6d1a6e4b4e..0171a9feaa 100644--- a/rust-lib/flowy-document/src/services/server/server_api.rs+++ b/rust-lib/flowy-document/src/services/server/server_api.rs@@ -1,6 +1,6 @@use crate::{errors::DocError, services::server::DocumentServerAPI};+use backend_service::{config::*, request::HttpRequestBuilder};use flowy_document_infra::entities::doc::{CreateDocParams, Doc, DocIdentifier, UpdateDocParams};-use flowy_net::{config::*, request::HttpRequestBuilder};use lib_infra::future::ResultFuture;pub struct DocServer {diff --git a/rust-lib/flowy-net/src/lib.rs b/rust-lib/flowy-net/src/lib.rsdeleted file mode 100644index 86f9bd59b2..0000000000--- a/rust-lib/flowy-net/src/lib.rs+++ /dev/null@@ -1,5 +0,0 @@-pub mod config;-pub mod errors;-#[cfg(feature = "flowy_request")]-pub mod request;-pub mod response;diff --git a/rust-lib/flowy-net/src/response/response_serde.rs b/rust-lib/flowy-net/src/response/response_serde.rsdeleted file mode 100644index 154b22f7ce..0000000000--- a/rust-lib/flowy-net/src/response/response_serde.rs+++ /dev/null@@ -1,123 +0,0 @@-// use crate::response::{FlowyResponse, ServerCode};-// use serde::{-// de::{self, MapAccess, Visitor},-// Deserialize,-// Deserializer,-// Serialize,-// };-// use std::{fmt, marker::PhantomData, str::FromStr};-//-// pub trait ServerData<'a>: Serialize + Deserialize<'a> + FromStr<Err = ()> {}-// impl<'de, T: ServerData<'de>> Deserialize<'de> for FlowyResponse<T> {-// fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>-// where-// D: Deserializer<'de>,-// {-// struct ServerResponseVisitor<T>(PhantomData<fn() -> T>);-// impl<'de, T> Visitor<'de> for ServerResponseVisitor<T>-// where-// T: ServerData<'de>,-// {-// type Value = FlowyResponse<T>;-//-// fn expecting(&self, formatter: &mut fmt::Formatter) ->-// fmt::Result { formatter.write_str("struct Duration") }-//-// fn visit_map<V>(self, mut map: V) -> Result<Self::Value,-// V::Error> where-// V: MapAccess<'de>,-// {-// let mut msg = None;-// let mut data: Option<T> = None;-// let mut code: Option<ServerCode> = None;-// while let Some(key) = map.next_key()? {-// match key {-// "msg" => {-// if msg.is_some() {-// return-// Err(de::Error::duplicate_field("msg")); }-// msg = Some(map.next_value()?);-// },-// "code" => {-// if code.is_some() {-// return-// Err(de::Error::duplicate_field("code")); }-// code = Some(map.next_value()?);-// },-// "data" => {-// if data.is_some() {-// return-// Err(de::Error::duplicate_field("data")); }-// data = match-// MapAccess::next_value::<DeserializeWith<T>>(&mut map) {-// Ok(wrapper) => wrapper.value, Err(err) =>-// return Err(err), };-// },-// _ => panic!(),-// }-// }-// let msg = msg.ok_or_else(||-// de::Error::missing_field("msg"))?; let code =-// code.ok_or_else(|| de::Error::missing_field("code"))?;-// Ok(Self::Value::new(data, msg, code)) }-// }-// const FIELDS: &'static [&'static str] = &["msg", "code", "data"];-// deserializer.deserialize_struct("ServerResponse", FIELDS,-// ServerResponseVisitor(PhantomData)) }-// }-//-// struct DeserializeWith<'de, T: ServerData<'de>> {-// value: Option<T>,-// phantom: PhantomData<&'de ()>,-// }-//-// impl<'de, T: ServerData<'de>> Deserialize<'de> for DeserializeWith<'de, T> {-// fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>-// where-// D: Deserializer<'de>,-// {-// Ok(DeserializeWith {-// value: match string_or_data(deserializer) {-// Ok(val) => val,-// Err(e) => return Err(e),-// },-// phantom: PhantomData,-// })-// }-// }-//-// fn string_or_data<'de, D, T>(deserializer: D) -> Result<Option<T>, D::Error>-// where-// D: Deserializer<'de>,-// T: ServerData<'de>,-// {-// struct StringOrData<T>(PhantomData<fn() -> T>);-// impl<'de, T: ServerData<'de>> Visitor<'de> for StringOrData<T> {-// type Value = Option<T>;-//-// fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {-// formatter.write_str("string or struct impl deserialize") }-//-// fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>-// where-// E: de::Error,-// {-// match FromStr::from_str(value) {-// Ok(val) => Ok(Some(val)),-// Err(_e) => Ok(None),-// }-// }-//-// fn visit_map<M>(self, map: M) -> Result<Self::Value, M::Error>-// where-// M: MapAccess<'de>,-// {-// match-// Deserialize::deserialize(de::value::MapAccessDeserializer::new(map)) {-// Ok(val) => Ok(Some(val)),-// Err(e) => Err(e),-// }-// }-// }-// deserializer.deserialize_any(StringOrData(PhantomData))-// }diff --git a/rust-lib/flowy-sdk/Cargo.toml b/rust-lib/flowy-sdk/Cargo.tomlindex 0b0b7faa27..f0f3d6d556 100644--- a/rust-lib/flowy-sdk/Cargo.toml+++ b/rust-lib/flowy-sdk/Cargo.toml@@ -15,7 +15,7 @@ flowy-database = { path = "../flowy-database" }flowy-document = { path = "../flowy-document" }flowy-document-infra = { path = "../flowy-document-infra" }lib-ws = { path = "../lib-ws" }-flowy-net = { path = "../flowy-net" }+backend-service = { path = "../backend-service" }tracing = { version = "0.1" }log = "0.4.14"futures-core = { version = "0.3", default-features = false }diff --git a/rust-lib/flowy-sdk/src/lib.rs b/rust-lib/flowy-sdk/src/lib.rsindex 3885ce3984..d736d37c54 100644--- a/rust-lib/flowy-sdk/src/lib.rs+++ b/rust-lib/flowy-sdk/src/lib.rs@@ -3,8 +3,8 @@ mod deps_resolve;pub mod module;use crate::deps_resolve::WorkspaceDepsResolver;+use backend_service::config::ServerConfig;use flowy_document::module::FlowyDocument;-use flowy_net::config::ServerConfig;use flowy_user::services::user::{UserSession, UserSessionBuilder, UserStatus};use flowy_workspace::{errors::WorkspaceError, prelude::WorkspaceController};use lib_dispatch::prelude::*;diff --git a/rust-lib/flowy-sdk/src/module.rs b/rust-lib/flowy-sdk/src/module.rsindex 47f1e47d2b..2f7a788923 100644--- a/rust-lib/flowy-sdk/src/module.rs+++ b/rust-lib/flowy-sdk/src/module.rs@@ -1,6 +1,6 @@use crate::deps_resolve::DocumentDepsResolver;+use backend_service::config::ServerConfig;use flowy_document::module::FlowyDocument;-use flowy_net::config::ServerConfig;use flowy_user::services::user::UserSession;use flowy_workspace::prelude::WorkspaceController;use lib_dispatch::prelude::Module;diff --git a/rust-lib/flowy-test/Cargo.toml b/rust-lib/flowy-test/Cargo.tomlindex 3506c6c02b..9662ea22ce 100644--- a/rust-lib/flowy-test/Cargo.toml+++ b/rust-lib/flowy-test/Cargo.toml@@ -13,7 +13,7 @@ flowy-workspace = { path = "../flowy-workspace", default-features = false}lib-infra = { path = "../lib-infra" }flowy-document = { path = "../flowy-document"}flowy-document-infra = { path = "../flowy-document-infra"}-flowy-net = { path = "../flowy-net"}+backend-service = { path = "../backend-service" }serde = { version = "1.0", features = ["derive"] }bincode = { version = "1.3"}diff --git a/rust-lib/flowy-test/src/lib.rs b/rust-lib/flowy-test/src/lib.rsindex 8941ca316d..257f758806 100644--- a/rust-lib/flowy-test/src/lib.rs+++ b/rust-lib/flowy-test/src/lib.rs@@ -3,7 +3,7 @@ mod helper;pub mod workspace;use crate::helper::*;-use flowy_net::config::ServerConfig;+use backend_service::config::ServerConfig;use flowy_sdk::{FlowySDK, FlowySDKConfig};use flowy_user::entities::UserProfile;use lib_infra::uuid;diff --git a/rust-lib/flowy-user/Cargo.toml b/rust-lib/flowy-user/Cargo.tomlindex d4a8e102b2..fdf2f61b01 100644--- a/rust-lib/flowy-user/Cargo.toml+++ b/rust-lib/flowy-user/Cargo.toml@@ -7,14 +7,13 @@ edition = "2018"[dependencies]flowy-user-infra = { path = "../flowy-user-infra" }-backend-api = { path = "../backend-api" }+backend-service = { path = "../backend-service" }derive_more = {version = "0.99", features = ["display"]}lib-dispatch = { path = "../lib-dispatch" }flowy-derive = { path = "../flowy-derive" }flowy-database = { path = "../flowy-database" }lib-sqlite = { path = "../lib-sqlite" }lib-infra = { path = "../lib-infra" }-flowy-net = { path = "../flowy-net", features = ["flowy_request"] }lib-ws = { path = "../lib-ws" }dart-notify = { path = "../dart-notify" }diff --git a/rust-lib/flowy-user/src/errors.rs b/rust-lib/flowy-user/src/errors.rsindex 315803881e..454f7aeffe 100644--- a/rust-lib/flowy-user/src/errors.rs+++ b/rust-lib/flowy-user/src/errors.rs@@ -92,15 +92,15 @@ impl std::convert::From<lib_sqlite::Error> for UserError {fn from(error: lib_sqlite::Error) -> Self { UserError::internal().context(error) }}-impl std::convert::From<flowy_net::errors::ServerError> for UserError {- fn from(error: flowy_net::errors::ServerError) -> Self {+impl std::convert::From<backend_service::errors::ServerError> for UserError {+ fn from(error: backend_service::errors::ServerError) -> Self {let (code, msg) = server_error_to_user_error(error);UserError::new(code, &msg)}}-use flowy_net::errors::ErrorCode as ServerErrorCode;-fn server_error_to_user_error(error: flowy_net::errors::ServerError) -> (ErrorCode, String) {+use backend_service::errors::ErrorCode as ServerErrorCode;+fn server_error_to_user_error(error: backend_service::errors::ServerError) -> (ErrorCode, String) {let code = match error.code {ServerErrorCode::UserUnauthorized => ErrorCode::UserUnauthorized,ServerErrorCode::PasswordNotMatch => ErrorCode::PasswordNotMatch,diff --git a/rust-lib/flowy-user/src/services/server/mod.rs b/rust-lib/flowy-user/src/services/server/mod.rsindex 4f45b2efb1..37cd3a5ce8 100644--- a/rust-lib/flowy-user/src/services/server/mod.rs+++ b/rust-lib/flowy-user/src/services/server/mod.rs@@ -9,7 +9,7 @@ use crate::{entities::{SignInParams, SignInResponse, SignUpParams, SignUpResponse, UpdateUserParams, UserProfile},errors::UserError,};-use flowy_net::config::ServerConfig;+use backend_service::config::ServerConfig;use lib_infra::future::ResultFuture;pub trait UserServerAPI {diff --git a/rust-lib/flowy-user/src/services/server/server_api.rs b/rust-lib/flowy-user/src/services/server/server_api.rsindex 346df33008..1a9198d9a2 100644--- a/rust-lib/flowy-user/src/services/server/server_api.rs+++ b/rust-lib/flowy-user/src/services/server/server_api.rs@@ -3,8 +3,7 @@ use crate::{errors::UserError,services::server::UserServerAPI,};-use backend_api::user_request::*;-use flowy_net::config::*;+use backend_service::{config::*, user_request::*};use lib_infra::future::ResultFuture;pub struct UserServer {@@ -62,7 +61,7 @@ impl UserServerAPI for UserServer {}// use crate::notify::*;-// use flowy_net::response::FlowyResponse;+// use backend_service::response::FlowyResponse;// use flowy_user_infra::errors::ErrorCode;// struct Middleware {}diff --git a/rust-lib/flowy-user/src/services/user/builder.rs b/rust-lib/flowy-user/src/services/user/builder.rsindex e6e265e7cb..394ea61a90 100644--- a/rust-lib/flowy-user/src/services/user/builder.rs+++ b/rust-lib/flowy-user/src/services/user/builder.rs@@ -1,5 +1,5 @@use crate::services::user::{UserSession, UserSessionConfig};-use flowy_net::config::ServerConfig;+use backend_service::config::ServerConfig;pub struct UserSessionBuilder {config: Option<UserSessionConfig>,diff --git a/rust-lib/flowy-user/src/services/user/user_session.rs b/rust-lib/flowy-user/src/services/user/user_session.rsindex 54e8161927..cf40227cde 100644--- a/rust-lib/flowy-user/src/services/user/user_session.rs+++ b/rust-lib/flowy-user/src/services/user/user_session.rs@@ -9,6 +9,7 @@ use crate::{notify::*,services::server::{construct_user_server, Server},};+use backend_service::config::ServerConfig;use flowy_database::{query_dsl::*,schema::{user_table, user_table::dsl},@@ -16,7 +17,6 @@ use flowy_database::{ExpressionMethods,UserDatabaseConnection,};-use flowy_net::config::ServerConfig;use lib_infra::kv::KV;use lib_sqlite::ConnectionPool;use lib_ws::{WsController, WsMessageHandler, WsState};diff --git a/rust-lib/flowy-workspace/Cargo.toml b/rust-lib/flowy-workspace/Cargo.tomlindex bed5db9859..65ba22d5a5 100644--- a/rust-lib/flowy-workspace/Cargo.toml+++ b/rust-lib/flowy-workspace/Cargo.toml@@ -16,8 +16,7 @@ lib-sqlite = { path = "../lib-sqlite" }lib-infra = { path = "../lib-infra" }dart-notify = { path = "../dart-notify" }lib-ot = { path = "../lib-ot" }-flowy-net = { path = "../flowy-net", features = ["flowy_request"] }-backend-api = { path = "../backend-api" }+backend-service = { path = "../backend-service" }parking_lot = "0.11"protobuf = {version = "2.18.0"}diff --git a/rust-lib/flowy-workspace/src/errors.rs b/rust-lib/flowy-workspace/src/errors.rsindex a048059cee..19e4113898 100644--- a/rust-lib/flowy-workspace/src/errors.rs+++ b/rust-lib/flowy-workspace/src/errors.rs@@ -1,8 +1,8 @@use bytes::Bytes;+use backend_service::errors::ErrorCode as ServerErrorCode;use flowy_derive::ProtoBuf;use flowy_document::errors::DocError;-use flowy_net::errors::ErrorCode as ServerErrorCode;pub use flowy_workspace_infra::errors::ErrorCode;use lib_dispatch::prelude::{EventResponse, ResponseBuilder};use std::{convert::TryInto, fmt, fmt::Debug};@@ -75,8 +75,8 @@ impl std::convert::From<flowy_document::errors::DocError> for WorkspaceError {fn from(error: DocError) -> Self { WorkspaceError::internal().context(error) }}-impl std::convert::From<flowy_net::errors::ServerError> for WorkspaceError {- fn from(error: flowy_net::errors::ServerError) -> Self {+impl std::convert::From<backend_service::errors::ServerError> for WorkspaceError {+ fn from(error: backend_service::errors::ServerError) -> Self {let code = server_error_to_workspace_error(error.code);WorkspaceError::new(code, &error.msg)}diff --git a/rust-lib/flowy-workspace/src/module.rs b/rust-lib/flowy-workspace/src/module.rsindex 3098eb494f..be8d2cde7d 100644--- a/rust-lib/flowy-workspace/src/module.rs+++ b/rust-lib/flowy-workspace/src/module.rs@@ -4,9 +4,9 @@ use crate::{handlers::*,services::{server::construct_workspace_server, AppController, TrashCan, ViewController, WorkspaceController},};+use backend_service::config::ServerConfig;use flowy_database::DBConnection;use flowy_document::module::FlowyDocument;-use flowy_net::config::ServerConfig;use lib_dispatch::prelude::*;use lib_sqlite::ConnectionPool;use std::sync::Arc;diff --git a/rust-lib/flowy-workspace/src/services/server/mod.rs b/rust-lib/flowy-workspace/src/services/server/mod.rsindex 0d966fae63..c507b3305b 100644--- a/rust-lib/flowy-workspace/src/services/server/mod.rs+++ b/rust-lib/flowy-workspace/src/services/server/mod.rs@@ -14,7 +14,7 @@ use crate::{},errors::WorkspaceError,};-use flowy_net::config::ServerConfig;+use backend_service::config::ServerConfig;use lib_infra::future::ResultFuture;use std::sync::Arc;diff --git a/rust-lib/flowy-workspace/src/services/server/server_api.rs b/rust-lib/flowy-workspace/src/services/server/server_api.rsindex f88dd55458..cb159e6a21 100644--- a/rust-lib/flowy-workspace/src/services/server/server_api.rs+++ b/rust-lib/flowy-workspace/src/services/server/server_api.rs@@ -9,8 +9,7 @@ use crate::{notify::{send_dart_notification, WorkspaceNotification},services::server::WorkspaceServerAPI,};-use backend_api::{middleware::*, workspace_request::*};-use flowy_net::config::ServerConfig;+use backend_service::{config::ServerConfig, middleware::*, workspace_request::*};use flowy_workspace_infra::errors::ErrorCode;use lib_infra::future::ResultFuture;diff --git a/rust-lib/lib-ws/Cargo.toml b/rust-lib/lib-ws/Cargo.tomlindex 6553edf0a7..1deef5e0a7 100644--- a/rust-lib/lib-ws/Cargo.toml+++ b/rust-lib/lib-ws/Cargo.toml@@ -7,7 +7,7 @@ edition = "2018"[dependencies]flowy-derive = { path = "../flowy-derive" }-flowy-net = { path = "../flowy-net" }+backend-service = { path = "../backend-service" }lib-infra = { path = "../lib-infra" }tokio-tungstenite = "0.15"diff --git a/rust-lib/lib-ws/src/ws.rs b/rust-lib/lib-ws/src/ws.rsindex ce6226550c..ec9435e074 100644--- a/rust-lib/lib-ws/src/ws.rs+++ b/rust-lib/lib-ws/src/ws.rs@@ -4,9 +4,9 @@ use crate::{WsMessage,WsModule,};+use backend_service::errors::ServerError;use bytes::Bytes;use dashmap::DashMap;-use flowy_net::errors::ServerError;use futures_channel::mpsc::{UnboundedReceiver, UnboundedSender};use futures_core::{ready, Stream};use lib_infra::retry::{Action, FixedInterval, Retry};