refactor: remove unuse crate references

This commit is contained in:
appflowy 2022-02-07 10:37:01 +08:00
parent 248473dddf
commit 680d130986
17 changed files with 30 additions and 43 deletions

View File

@ -115,12 +115,6 @@ script = [
echo PRODUCT_EXT: ${PRODUCT_EXT}
echo APP_ENVIRONMENT: ${APP_ENVIRONMENT}
echo ${platforms}
echo "-------- Flutter --------"
flutter doctor
echo "-------- Rust --------"
rustup show
'''
]
script_runner = "@shell"

View File

@ -26,10 +26,7 @@ once_cell = "1"
lib-dispatch = {path = "../lib-dispatch" }
flowy-sdk = {path = "../flowy-sdk"}
dart-notify = {path = "../dart-notify" }
flowy-derive = {path = "../../../shared-lib/flowy-derive" }
backend-service = { path = "../../../shared-lib/backend-service" }
[features]
flutter = ["dart-notify/dart"]

View File

@ -8,7 +8,9 @@ use crate::{
c::{extend_front_four_bytes_into_bytes, forget_rust},
model::{FFIRequest, FFIResponse},
};
use flowy_sdk::get_client_server_configuration;
use flowy_sdk::*;
use lib_dispatch::prelude::ToBytes;
use lib_dispatch::prelude::*;
use once_cell::sync::OnceCell;
use std::{ffi::CStr, os::raw::c_char};
@ -80,9 +82,6 @@ pub extern "C" fn set_stream_port(port: i64) -> i32 {
#[no_mangle]
pub extern "C" fn link_me_please() {}
use backend_service::configuration::get_client_server_configuration;
use lib_dispatch::prelude::ToBytes;
#[inline(always)]
async fn post_to_flutter(response: EventResponse, port: i64) {
let isolate = allo_isolate::Isolate::new(port);

View File

@ -18,17 +18,17 @@ use lib_infra::future::FutureResult;
use std::sync::Arc;
use tokio::sync::broadcast;
pub struct CoreHttpCloudService {
pub struct FolderHttpCloudService {
config: ClientServerConfiguration,
}
impl CoreHttpCloudService {
pub fn new(config: ClientServerConfiguration) -> CoreHttpCloudService {
impl FolderHttpCloudService {
pub fn new(config: ClientServerConfiguration) -> FolderHttpCloudService {
Self { config }
}
}
impl FolderCouldServiceV1 for CoreHttpCloudService {
impl FolderCouldServiceV1 for FolderHttpCloudService {
fn init(&self) {}
fn create_workspace(&self, token: &str, params: CreateWorkspaceParams) -> FutureResult<Workspace, FlowyError> {

View File

@ -6,3 +6,5 @@ pub mod local_server;
pub mod module;
pub mod protobuf;
pub mod ws;
pub use backend_service::configuration::{get_client_server_configuration, ClientServerConfiguration};

View File

@ -26,7 +26,6 @@ parking_lot = "0.11"
flowy-collaboration = { path = "../../../shared-lib/flowy-collaboration" }
lib-ws = { path = "../../../shared-lib/lib-ws" }
backend-service = { path = "../../../shared-lib/backend-service" }
lib-infra = { path = "../../../shared-lib/lib-infra" }
[dev-dependencies]

View File

@ -1,4 +1,3 @@
use backend_service::configuration::ClientServerConfiguration;
use bytes::Bytes;
use flowy_collaboration::entities::ws_data::ClientRevisionWSData;
use flowy_database::ConnectionPool;
@ -6,6 +5,7 @@ use flowy_document::{
errors::{internal_error, FlowyError},
DocumentCloudService, DocumentUser, FlowyDocumentManager,
};
use flowy_net::ClientServerConfiguration;
use flowy_net::{
http_server::document::DocumentHttpCloudService, local_server::LocalServer, ws::connection::FlowyWebSocketConnect,
};

View File

@ -1,4 +1,3 @@
use backend_service::configuration::ClientServerConfiguration;
use bytes::Bytes;
use flowy_collaboration::entities::ws_data::ClientRevisionWSData;
use flowy_database::ConnectionPool;
@ -8,8 +7,9 @@ use flowy_folder::{
errors::{internal_error, FlowyError},
event_map::{FolderCouldServiceV1, WorkspaceDatabase, WorkspaceUser},
};
use flowy_net::ClientServerConfiguration;
use flowy_net::{
http_server::core::CoreHttpCloudService, local_server::LocalServer, ws::connection::FlowyWebSocketConnect,
http_server::core::FolderHttpCloudService, local_server::LocalServer, ws::connection::FlowyWebSocketConnect,
};
use flowy_sync::{RevisionWebSocket, WSStateReceiver};
use flowy_user::services::UserSession;
@ -31,7 +31,7 @@ impl FolderDepsResolver {
let database: Arc<dyn WorkspaceDatabase> = Arc::new(WorkspaceDatabaseImpl(user_session));
let web_socket = Arc::new(FolderWebSocketImpl(ws_conn.clone()));
let cloud_service: Arc<dyn FolderCouldServiceV1> = match local_server {
None => Arc::new(CoreHttpCloudService::new(server_config.clone())),
None => Arc::new(FolderHttpCloudService::new(server_config.clone())),
Some(local_server) => local_server,
};

View File

@ -1,4 +1,4 @@
use backend_service::configuration::ClientServerConfiguration;
use flowy_net::ClientServerConfiguration;
use flowy_net::{http_server::user::UserHttpCloudService, local_server::LocalServer};
use flowy_user::event_map::UserCloudService;

View File

@ -1,8 +1,11 @@
mod deps_resolve;
pub mod module;
pub use flowy_net::get_client_server_configuration;
use crate::deps_resolve::*;
use backend_service::configuration::ClientServerConfiguration;
use flowy_document::FlowyDocumentManager;
use flowy_folder::{controller::FolderManager, errors::FlowyError};
use flowy_net::ClientServerConfiguration;
use flowy_net::{
entities::NetworkType,
local_server::LocalServer,
@ -10,8 +13,6 @@ use flowy_net::{
};
use flowy_user::services::{notifier::UserStatus, UserSession, UserSessionConfig};
use lib_dispatch::prelude::*;
use flowy_document::FlowyDocumentManager;
use lib_dispatch::util::tokio_default_runtime;
use module::mk_modules;
pub use module::*;

View File

@ -13,7 +13,6 @@ flowy-folder = { path = "../flowy-folder", default-features = false}
lib-dispatch = { path = "../lib-dispatch" }
flowy-collaboration = { path = "../../../shared-lib/flowy-collaboration" }
backend-service = { path = "../../../shared-lib/backend-service" }
lib-ot = { path = "../../../shared-lib/lib-ot" }
lib-infra = { path = "../../../shared-lib/lib-infra" }

View File

@ -2,7 +2,7 @@ pub mod event_builder;
pub mod helper;
use crate::helper::*;
use backend_service::configuration::{get_client_server_configuration, ClientServerConfiguration};
use flowy_net::{get_client_server_configuration, ClientServerConfiguration};
use flowy_sdk::{FlowySDK, FlowySDKConfig};
use flowy_user::entities::UserProfile;
use lib_infra::uuid_string;

1
shared-lib/Cargo.lock generated
View File

@ -1118,7 +1118,6 @@ dependencies = [
name = "lib-ws"
version = "0.1.0"
dependencies = [
"backend-service",
"bytes",
"dashmap",
"env_logger 0.8.4",

View File

@ -7,7 +7,6 @@ edition = "2018"
[dependencies]
flowy-derive = { path = "../flowy-derive" }
backend-service = { path = "../backend-service" }
lib-infra = { path = "../lib-infra" }
tokio-tungstenite = "0.15"

View File

@ -2,6 +2,7 @@ use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
use futures_channel::mpsc::TrySendError;
use std::fmt::Debug;
use strum_macros::Display;
use tokio::sync::oneshot::error::RecvError;
use tokio_tungstenite::tungstenite::{http::StatusCode, Message};
use url::ParseError;
@ -83,6 +84,12 @@ impl std::convert::From<futures_channel::mpsc::TrySendError<Message>> for WSErro
}
}
impl std::convert::From<RecvError> for WSError {
fn from(error: RecvError) -> Self {
WSError::internal().context(error)
}
}
impl std::convert::From<tokio_tungstenite::tungstenite::Error> for WSError {
fn from(error: tokio_tungstenite::tungstenite::Error) -> Self {
match error {

View File

@ -1,8 +0,0 @@
#![cfg_attr(rustfmt, rustfmt::skip)]
// Auto-generated, do not edit
mod errors;
pub use errors::*;
mod msg;
pub use msg::*;

View File

@ -4,7 +4,6 @@ use crate::{
errors::WSError,
WSChannel, WebSocketRawMessage,
};
use backend_service::errors::ServerError;
use bytes::Bytes;
use dashmap::DashMap;
use futures_channel::mpsc::{UnboundedReceiver, UnboundedSender};
@ -73,7 +72,7 @@ impl WSController {
Ok(())
}
pub async fn start(&self, addr: String) -> Result<(), ServerError> {
pub async fn start(&self, addr: String) -> Result<(), WSError> {
*self.addr.write().await = Some(addr.clone());
let strategy = FixedInterval::from_millis(5000).take(3);
self.connect(addr, strategy).await
@ -89,7 +88,7 @@ impl WSController {
}
}
async fn connect<T, I>(&self, addr: String, strategy: T) -> Result<(), ServerError>
async fn connect<T, I>(&self, addr: String, strategy: T) -> Result<(), WSError>
where
T: IntoIterator<IntoIter = I, Item = Duration>,
I: Iterator<Item = Duration> + Send + 'static,
@ -100,7 +99,7 @@ impl WSController {
return Ok(());
}
let (ret, rx) = oneshot::channel::<Result<(), ServerError>>();
let (ret, rx) = oneshot::channel::<Result<(), WSError>>();
*self.addr.write().await = Some(addr.clone());
let action = WSConnectAction {
addr,
@ -133,14 +132,14 @@ impl WSController {
.write()
.await
.update_state(WSConnectState::Disconnected);
let _ = ret.send(Err(ServerError::internal().context(e)));
let _ = ret.send(Err(WSError::internal().context(e)));
}
}
});
rx.await?
}
pub async fn retry(&self, count: usize) -> Result<(), ServerError> {
pub async fn retry(&self, count: usize) -> Result<(), WSError> {
if !self.conn_state_notify.read().await.conn_state.is_disconnected() {
return Ok(());
}