Просмотр исходного кода

[rust]: separate workspace crates

appflowy 3 лет назад
Родитель
Сommit
92010853c2
33 измененных файлов с 37 добавлено и 69 удалено
  1. 1 1
      backend/Cargo.toml
  2. 4 4
      rust-lib/dart-ffi/Cargo.toml
  3. 1 0
      rust-lib/flowy-document/src/sql_tables/doc/rev_sql.rs
  4. 1 4
      rust-lib/flowy-workspace/Cargo.toml
  5. 0 0
      rust-lib/flowy-workspace/src/handlers/app_handler.rs
  6. 0 0
      rust-lib/flowy-workspace/src/handlers/mod.rs
  7. 0 0
      rust-lib/flowy-workspace/src/handlers/trash_handler.rs
  8. 0 0
      rust-lib/flowy-workspace/src/handlers/view_handler.rs
  9. 0 0
      rust-lib/flowy-workspace/src/handlers/workspace_handler.rs
  10. 7 7
      rust-lib/flowy-workspace/src/lib.rs
  11. 2 8
      rust-lib/flowy-workspace/src/module.rs
  12. 0 0
      rust-lib/flowy-workspace/src/notify/mod.rs
  13. 0 0
      rust-lib/flowy-workspace/src/notify/observable.rs
  14. 3 8
      rust-lib/flowy-workspace/src/services/app_controller.rs
  15. 0 6
      rust-lib/flowy-workspace/src/services/mod.rs
  16. 1 1
      rust-lib/flowy-workspace/src/services/server/middleware.rs
  17. 3 6
      rust-lib/flowy-workspace/src/services/trash_can.rs
  18. 2 0
      rust-lib/flowy-workspace/src/services/util.rs
  19. 3 8
      rust-lib/flowy-workspace/src/services/view_controller.rs
  20. 3 10
      rust-lib/flowy-workspace/src/services/workspace_controller.rs
  21. 1 1
      rust-lib/flowy-workspace/src/sql_tables/app/app_sql.rs
  22. 1 1
      rust-lib/flowy-workspace/src/sql_tables/app/app_table.rs
  23. 0 0
      rust-lib/flowy-workspace/src/sql_tables/app/mod.rs
  24. 0 0
      rust-lib/flowy-workspace/src/sql_tables/mod.rs
  25. 0 0
      rust-lib/flowy-workspace/src/sql_tables/trash/mod.rs
  26. 1 1
      rust-lib/flowy-workspace/src/sql_tables/trash/trash_sql.rs
  27. 0 0
      rust-lib/flowy-workspace/src/sql_tables/trash/trash_table.rs
  28. 0 0
      rust-lib/flowy-workspace/src/sql_tables/view/mod.rs
  29. 1 1
      rust-lib/flowy-workspace/src/sql_tables/view/view_sql.rs
  30. 1 1
      rust-lib/flowy-workspace/src/sql_tables/view/view_table.rs
  31. 0 0
      rust-lib/flowy-workspace/src/sql_tables/workspace/mod.rs
  32. 1 1
      rust-lib/flowy-workspace/src/sql_tables/workspace/workspace_sql.rs
  33. 0 0
      rust-lib/flowy-workspace/src/sql_tables/workspace/workspace_table.rs

+ 1 - 1
backend/Cargo.toml

@@ -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" }

+ 4 - 4
rust-lib/dart-ffi/Cargo.toml

@@ -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]

+ 1 - 0
rust-lib/flowy-document/src/sql_tables/doc/rev_sql.rs

@@ -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()))

+ 1 - 4
rust-lib/flowy-workspace/Cargo.toml

@@ -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 = []

+ 0 - 0
rust-lib/flowy-workspace/src/services/handlers/app_handler.rs → rust-lib/flowy-workspace/src/handlers/app_handler.rs


+ 0 - 0
rust-lib/flowy-workspace/src/services/handlers/mod.rs → rust-lib/flowy-workspace/src/handlers/mod.rs


+ 0 - 0
rust-lib/flowy-workspace/src/services/handlers/trash_handler.rs → rust-lib/flowy-workspace/src/handlers/trash_handler.rs


+ 0 - 0
rust-lib/flowy-workspace/src/services/handlers/view_handler.rs → rust-lib/flowy-workspace/src/handlers/view_handler.rs


+ 0 - 0
rust-lib/flowy-workspace/src/services/handlers/workspace_handler.rs → rust-lib/flowy-workspace/src/handlers/workspace_handler.rs


+ 7 - 7
rust-lib/flowy-workspace/src/lib.rs

@@ -1,12 +1,9 @@
-#[cfg(feature = "flowy_client_sdk")]
+pub use flowy_workspace_infra::entities;
+
 pub mod event;
-#[cfg(feature = "flowy_client_sdk")]
 pub mod module;
-#[cfg(feature = "flowy_client_sdk")]
 mod services;
 
-pub use flowy_workspace_infra::entities;
-
 #[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::*};
 }

+ 2 - 8
rust-lib/flowy-workspace/src/module.rs

@@ -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 {}

+ 0 - 0
rust-lib/flowy-workspace/src/services/notify/mod.rs → rust-lib/flowy-workspace/src/notify/mod.rs


+ 0 - 0
rust-lib/flowy-workspace/src/services/notify/observable.rs → rust-lib/flowy-workspace/src/notify/observable.rs


+ 3 - 8
rust-lib/flowy-workspace/src/services/app_controller.rs

@@ -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 {

+ 0 - 6
rust-lib/flowy-workspace/src/services/mod.rs

@@ -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;

+ 1 - 1
rust-lib/flowy-workspace/src/services/server/middleware.rs

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

+ 3 - 6
rust-lib/flowy-workspace/src/services/trash_can.rs

@@ -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 {

+ 2 - 0
rust-lib/flowy-workspace/src/services/util.rs

@@ -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,

+ 3 - 8
rust-lib/flowy-workspace/src/services/view_controller.rs

@@ -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 {

+ 3 - 10
rust-lib/flowy-workspace/src/services/workspace_controller.rs

@@ -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 {

+ 1 - 1
rust-lib/flowy-workspace/src/services/sql_tables/app/app_sql.rs → rust-lib/flowy-workspace/src/sql_tables/app/app_sql.rs

@@ -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 {}

+ 1 - 1
rust-lib/flowy-workspace/src/services/sql_tables/app/app_table.rs → rust-lib/flowy-workspace/src/sql_tables/app/app_table.rs

@@ -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)]

+ 0 - 0
rust-lib/flowy-workspace/src/services/sql_tables/app/mod.rs → rust-lib/flowy-workspace/src/sql_tables/app/mod.rs


+ 0 - 0
rust-lib/flowy-workspace/src/services/sql_tables/mod.rs → rust-lib/flowy-workspace/src/sql_tables/mod.rs


+ 0 - 0
rust-lib/flowy-workspace/src/services/sql_tables/trash/mod.rs → rust-lib/flowy-workspace/src/sql_tables/trash/mod.rs


+ 1 - 1
rust-lib/flowy-workspace/src/services/sql_tables/trash/trash_sql.rs → rust-lib/flowy-workspace/src/sql_tables/trash/trash_sql.rs

@@ -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 {}

+ 0 - 0
rust-lib/flowy-workspace/src/services/sql_tables/trash/trash_table.rs → rust-lib/flowy-workspace/src/sql_tables/trash/trash_table.rs


+ 0 - 0
rust-lib/flowy-workspace/src/services/sql_tables/view/mod.rs → rust-lib/flowy-workspace/src/sql_tables/view/mod.rs


+ 1 - 1
rust-lib/flowy-workspace/src/services/sql_tables/view/view_sql.rs → rust-lib/flowy-workspace/src/sql_tables/view/view_sql.rs

@@ -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 {}

+ 1 - 1
rust-lib/flowy-workspace/src/services/sql_tables/view/view_table.rs → rust-lib/flowy-workspace/src/sql_tables/view/view_table.rs

@@ -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)]

+ 0 - 0
rust-lib/flowy-workspace/src/services/sql_tables/workspace/mod.rs → rust-lib/flowy-workspace/src/sql_tables/workspace/mod.rs


+ 1 - 1
rust-lib/flowy-workspace/src/services/sql_tables/workspace/workspace_sql.rs → rust-lib/flowy-workspace/src/sql_tables/workspace/workspace_sql.rs

@@ -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 {}

+ 0 - 0
rust-lib/flowy-workspace/src/services/sql_tables/workspace/workspace_table.rs → rust-lib/flowy-workspace/src/sql_tables/workspace/workspace_table.rs