[rust]: separate workspace crates

This commit is contained in:
appflowy 2021-11-08 10:43:14 +08:00
parent c4d7bf61fd
commit 92010853c2
33 changed files with 39 additions and 71 deletions

View File

@ -100,7 +100,7 @@ once_cell = "1.7.2"
linkify = "0.5.0"
backend = { path = ".", features = ["flowy_test"]}
flowy-user = { path = "../rust-lib/flowy-user", features = ["http_server"] }
flowy-workspace = { path = "../rust-lib/flowy-workspace", default-features = false, features = ["http_server", "backend_service"] }
flowy-workspace = { path = "../rust-lib/flowy-workspace", default-features = false, features = ["http_server"] }
flowy-ws = { path = "../rust-lib/flowy-ws" }
flowy-sdk = { path = "../rust-lib/flowy-sdk", features = ["http_server"] }
flowy-test = { path = "../rust-lib/flowy-test" }

View File

@ -7,11 +7,11 @@ edition = "2018"
[lib]
name = "dart_ffi"
# this value will change depending on the target os
# for iOS it would be `rlib`
# for Macos it would be `rlib`
# for iOS it would be `cdylib`
# for Macos it would be `cdylib`
# for android it would be `c-dylib`
# default rlib
crate-type = ["rlib"]
# default cdylib
crate-type = ["cdylib"]
[dependencies]

View File

@ -39,6 +39,7 @@ impl RevTableSql {
Ok(())
}
#[allow(dead_code)]
pub(crate) fn update_rev_table(&self, changeset: RevChangeset, conn: &SqliteConnection) -> Result<(), DocError> {
let filter = dsl::rev_table
.filter(rev_id.eq(changeset.rev_id.as_ref()))

View File

@ -46,7 +46,4 @@ serial_test = "0.5.1"
[features]
default = ["flowy_client_sdk", "backend_service"]
http_server = []
flowy_client_sdk = []
backend_service = []
http_server = []

View File

@ -1,12 +1,9 @@
#[cfg(feature = "flowy_client_sdk")]
pub mod event;
#[cfg(feature = "flowy_client_sdk")]
pub mod module;
#[cfg(feature = "flowy_client_sdk")]
mod services;
pub use flowy_workspace_infra::entities;
pub mod event;
pub mod module;
mod services;
#[macro_use]
mod macros;
@ -14,10 +11,13 @@ mod macros;
extern crate flowy_database;
pub mod errors;
pub mod handlers;
mod notify;
pub mod protobuf;
mod sql_tables;
#[cfg(feature = "flowy_client_sdk")]
pub mod prelude {
pub use crate::{errors::*, module::*, services::*};
pub use flowy_workspace_infra::entities::{app::*, trash::*, view::*, workspace::*};
pub use crate::{errors::*, module::*, services::*};
}

View File

@ -9,14 +9,8 @@ use flowy_sqlite::ConnectionPool;
use crate::{
errors::WorkspaceError,
event::WorkspaceEvent,
services::{
handlers::*,
server::construct_workspace_server,
AppController,
TrashCan,
ViewController,
WorkspaceController,
},
handlers::*,
services::{server::construct_workspace_server, AppController, TrashCan, ViewController, WorkspaceController},
};
pub trait WorkspaceDeps: WorkspaceUser + WorkspaceDatabase {}

View File

@ -11,14 +11,9 @@ use crate::{
},
errors::*,
module::{WorkspaceDatabase, WorkspaceUser},
services::{
helper::spawn,
notify::*,
server::Server,
sql_tables::app::{AppTable, AppTableChangeset, AppTableSql},
TrashCan,
TrashEvent,
},
notify::*,
services::{helper::spawn, server::Server, TrashCan, TrashEvent},
sql_tables::app::{AppTable, AppTableChangeset, AppTableSql},
};
pub(crate) struct AppController {

View File

@ -5,14 +5,8 @@ pub use workspace_controller::*;
mod app_controller;
mod database;
#[cfg(feature = "flowy_client_sdk")]
pub mod handlers;
mod helper;
#[cfg(feature = "flowy_client_sdk")]
mod notify;
pub mod server;
#[cfg(feature = "flowy_client_sdk")]
mod sql_tables;
mod trash_can;
mod util;
mod view_controller;

View File

@ -6,7 +6,7 @@ use flowy_net::{request::ResponseMiddleware, response::FlowyResponse};
use crate::{
errors::{ErrorCode, WorkspaceError},
services::notify::*,
notify::*,
};
lazy_static! {

View File

@ -9,12 +9,9 @@ use crate::{
entities::trash::{RepeatedTrash, Trash, TrashIdentifier, TrashIdentifiers, TrashType},
errors::{WorkspaceError, WorkspaceResult},
module::{WorkspaceDatabase, WorkspaceUser},
services::{
helper::spawn,
notify::{send_anonymous_dart_notification, WorkspaceNotification},
server::Server,
sql_tables::trash::TrashTableSql,
},
notify::{send_anonymous_dart_notification, WorkspaceNotification},
services::{helper::spawn, server::Server},
sql_tables::trash::TrashTableSql,
};
pub struct TrashCan {

View File

@ -11,6 +11,7 @@ use std::{
pub(crate) type Builder<Fut> = Box<dyn Fn(String, Server) -> Fut + Send + Sync>;
#[allow(dead_code)]
pub(crate) struct RetryAction<Fut, T, E> {
token: String,
server: Server,
@ -20,6 +21,7 @@ pub(crate) struct RetryAction<Fut, T, E> {
}
impl<Fut, T, E> RetryAction<Fut, T, E> {
#[allow(dead_code)]
pub(crate) fn new<F>(server: Server, user: Arc<dyn WorkspaceUser>, builder: F) -> Self
where
Fut: Future<Output = Result<T, E>> + Send + Sync + 'static,

View File

@ -15,14 +15,9 @@ use crate::{
},
errors::{internal_error, WorkspaceError, WorkspaceResult},
module::{WorkspaceDatabase, WorkspaceUser},
services::{
helper::spawn,
notify::{send_dart_notification, WorkspaceNotification},
server::Server,
sql_tables::view::{ViewTable, ViewTableChangeset, ViewTableSql},
TrashCan,
TrashEvent,
},
notify::{send_dart_notification, WorkspaceNotification},
services::{helper::spawn, server::Server, TrashCan, TrashEvent},
sql_tables::view::{ViewTable, ViewTableChangeset, ViewTableSql},
};
pub(crate) struct ViewController {

View File

@ -7,16 +7,9 @@ use crate::{
entities::{app::RepeatedApp, workspace::*},
errors::*,
module::{WorkspaceDatabase, WorkspaceUser},
services::{
helper::spawn,
notify::*,
read_local_workspace_apps,
server::Server,
sql_tables::workspace::{WorkspaceTable, WorkspaceTableChangeset, WorkspaceTableSql},
AppController,
TrashCan,
ViewController,
},
notify::*,
services::{helper::spawn, read_local_workspace_apps, server::Server, AppController, TrashCan, ViewController},
sql_tables::workspace::{WorkspaceTable, WorkspaceTableChangeset, WorkspaceTableSql},
};
pub struct WorkspaceController {

View File

@ -6,7 +6,7 @@ use flowy_database::{
use crate::{
errors::WorkspaceError,
services::sql_tables::app::{AppTable, AppTableChangeset},
sql_tables::app::{AppTable, AppTableChangeset},
};
pub struct AppTableSql {}

View File

@ -11,7 +11,7 @@ use crate::{
trash::{Trash, TrashType},
view::RepeatedView,
},
services::sql_tables::workspace::WorkspaceTable,
sql_tables::workspace::WorkspaceTable,
};
#[derive(PartialEq, Clone, Debug, Queryable, Identifiable, Insertable, Associations)]

View File

@ -7,7 +7,7 @@ use flowy_database::{
use crate::{
entities::trash::{RepeatedTrash, Trash},
errors::WorkspaceError,
services::sql_tables::trash::{TrashTable, TrashTableChangeset},
sql_tables::trash::{TrashTable, TrashTableChangeset},
};
pub struct TrashTableSql {}

View File

@ -6,7 +6,7 @@ use flowy_database::{
use crate::{
errors::WorkspaceError,
services::sql_tables::view::{ViewTable, ViewTableChangeset},
sql_tables::view::{ViewTable, ViewTableChangeset},
};
pub struct ViewTableSql {}

View File

@ -8,7 +8,7 @@ use crate::{
trash::{Trash, TrashType},
view::{RepeatedView, UpdateViewParams, View, ViewType},
},
services::sql_tables::app::AppTable,
sql_tables::app::AppTable,
};
#[derive(PartialEq, Clone, Debug, Queryable, Identifiable, Insertable, Associations)]

View File

@ -7,7 +7,7 @@ use flowy_database::{
use crate::{
errors::WorkspaceError,
services::sql_tables::workspace::{WorkspaceTable, WorkspaceTableChangeset},
sql_tables::workspace::{WorkspaceTable, WorkspaceTableChangeset},
};
pub(crate) struct WorkspaceTableSql {}