ソースを参照

rename flowy-sys to flowy-dispatch

appflowy 3 年 前
コミット
53a041b6cd
50 ファイル変更107 行追加269 行削除
  1. 2 2
      .idea/appflowy_client.iml
  2. 37 35
      app_flowy/packages/flowy_sdk/lib/dispatch/code_gen.dart
  3. 2 28
      app_flowy/packages/flowy_sdk/lib/dispatch/dispatch.dart
  4. 0 35
      app_flowy/packages/flowy_sdk/lib/dispatch/flowy_error.dart
  5. 1 1
      app_flowy/packages/flowy_sdk/lib/flowy_sdk.dart
  6. 4 0
      doc/architecture.md
  7. 1 1
      rust-lib/Cargo.toml
  8. 1 1
      rust-lib/dart-ffi/Cargo.toml
  9. 2 2
      rust-lib/dart-ffi/src/lib.rs
  10. 1 1
      rust-lib/dart-ffi/src/model/ffi_request.rs
  11. 1 1
      rust-lib/dart-ffi/src/model/ffi_response.rs
  12. 1 1
      rust-lib/flowy-dispatch/Cargo.toml
  13. 0 0
      rust-lib/flowy-dispatch/src/data.rs
  14. 6 23
      rust-lib/flowy-dispatch/src/dispatch.rs
  15. 0 0
      rust-lib/flowy-dispatch/src/error/error.rs
  16. 0 0
      rust-lib/flowy-dispatch/src/error/mod.rs
  17. 1 2
      rust-lib/flowy-dispatch/src/lib.rs
  18. 0 0
      rust-lib/flowy-dispatch/src/module/container.rs
  19. 0 0
      rust-lib/flowy-dispatch/src/module/data.rs
  20. 0 0
      rust-lib/flowy-dispatch/src/module/mod.rs
  21. 0 0
      rust-lib/flowy-dispatch/src/module/module.rs
  22. 0 0
      rust-lib/flowy-dispatch/src/request/mod.rs
  23. 0 0
      rust-lib/flowy-dispatch/src/request/payload.rs
  24. 0 0
      rust-lib/flowy-dispatch/src/request/request.rs
  25. 0 0
      rust-lib/flowy-dispatch/src/response/builder.rs
  26. 0 0
      rust-lib/flowy-dispatch/src/response/mod.rs
  27. 0 0
      rust-lib/flowy-dispatch/src/response/responder.rs
  28. 0 0
      rust-lib/flowy-dispatch/src/response/response.rs
  29. 0 0
      rust-lib/flowy-dispatch/src/service/boxed.rs
  30. 0 0
      rust-lib/flowy-dispatch/src/service/handler.rs
  31. 0 0
      rust-lib/flowy-dispatch/src/service/mod.rs
  32. 0 0
      rust-lib/flowy-dispatch/src/service/service.rs
  33. 35 4
      rust-lib/flowy-dispatch/src/system.rs
  34. 0 0
      rust-lib/flowy-dispatch/src/util/mod.rs
  35. 0 0
      rust-lib/flowy-dispatch/src/util/ready.rs
  36. 2 2
      rust-lib/flowy-dispatch/tests/api/helper.rs
  37. 0 0
      rust-lib/flowy-dispatch/tests/api/main.rs
  38. 1 1
      rust-lib/flowy-dispatch/tests/api/module.rs
  39. 1 1
      rust-lib/flowy-sdk/Cargo.toml
  40. 1 1
      rust-lib/flowy-sdk/src/lib.rs
  41. 1 1
      rust-lib/flowy-sdk/src/module.rs
  42. 0 4
      rust-lib/flowy-sys/src/rt/mod.rs
  43. 0 34
      rust-lib/flowy-sys/src/rt/runtime.rs
  44. 1 1
      rust-lib/flowy-test/Cargo.toml
  45. 2 2
      rust-lib/flowy-test/src/lib.rs
  46. 1 1
      rust-lib/flowy-user/Cargo.toml
  47. 1 1
      rust-lib/flowy-user/src/handlers/auth.rs
  48. 1 1
      rust-lib/flowy-user/src/module.rs
  49. 0 1
      scripts/makefile/desktop.toml
  50. 0 81
      scripts/makefile/tool.toml

+ 2 - 2
.idea/appflowy_client.iml

@@ -5,8 +5,8 @@
       <sourceFolder url="file://$MODULE_DIR$/rust-lib/flowy-ast/src" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/rust-lib/flowy-derive/src" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/rust-lib/flowy-derive/tests" isTestSource="true" />
-      <sourceFolder url="file://$MODULE_DIR$/rust-lib/flowy-sys/src" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/rust-lib/flowy-sys/tests" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/rust-lib/flowy-dispatch/src" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/rust-lib/flowy-dispatch/tests" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/rust-lib/dart-ffi/src" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/rust-lib/flowy-log/src" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/rust-lib/flowy-sdk/src" isTestSource="false" />

+ 37 - 35
app_flowy/packages/flowy_sdk/lib/dispatch/code_gen.dart

@@ -1,46 +1,48 @@
+
+
 /// Auto gen code from rust ast, do not edit
 part of 'dispatch.dart';
-
 class UserEventAuthCheck {
-  UserSignInParams params;
-  UserEventAuthCheck(this.params);
+    UserSignInParams params;
+    UserEventAuthCheck(this.params);
 
-  Future<Either<UserSignInResult, FlowyError>> send() {
+    Future<Either<UserSignInResult, FlowyError>> send() {
     return paramsToBytes(params).fold(
-      (bytes) {
-        final request = FFIRequest.create()
-          ..event = UserEvent.AuthCheck.toString()
-          ..payload = bytes;
-
-        return Dispatch.asyncRequest(request)
-            .then((bytesResult) => bytesResult.fold(
-                  (bytes) => left(UserSignInResult.fromBuffer(bytes)),
-                  (error) => right(error),
-                ));
-      },
-      (err) => Future(() => right(err)),
-    );
-  }
+        (bytes) {
+          final request = FFIRequest.create()
+            ..event = UserEvent.AuthCheck.toString()
+            ..payload = bytes;
+
+          return Dispatch.asyncRequest(request)
+              .then((bytesResult) => bytesResult.fold(
+                    (bytes) => left(UserSignInResult.fromBuffer(bytes)),
+                    (error) => right(error),
+                  ));
+        },
+        (err) => Future(() => right(err)),
+        );
+    }
 }
 
 class UserEventSignIn {
-  UserSignInParams params;
-  UserEventSignIn(this.params);
+    UserSignInParams params;
+    UserEventSignIn(this.params);
 
-  Future<Either<UserSignInResult, FlowyError>> send() {
+    Future<Either<UserSignInResult, FlowyError>> send() {
     return paramsToBytes(params).fold(
-      (bytes) {
-        final request = FFIRequest.create()
-          ..event = UserEvent.SignIn.toString()
-          ..payload = bytes;
-
-        return Dispatch.asyncRequest(request)
-            .then((bytesResult) => bytesResult.fold(
-                  (bytes) => left(UserSignInResult.fromBuffer(bytes)),
-                  (error) => right(error),
-                ));
-      },
-      (err) => Future(() => right(err)),
-    );
-  }
+        (bytes) {
+          final request = FFIRequest.create()
+            ..event = UserEvent.SignIn.toString()
+            ..payload = bytes;
+
+          return Dispatch.asyncRequest(request)
+              .then((bytesResult) => bytesResult.fold(
+                    (bytes) => left(UserSignInResult.fromBuffer(bytes)),
+                    (error) => right(error),
+                  ));
+        },
+        (err) => Future(() => right(err)),
+        );
+    }
 }
+

+ 2 - 28
app_flowy/packages/flowy_sdk/lib/dispatch/dispatch.dart

@@ -1,7 +1,5 @@
 import 'dart:ffi';
 import 'package:dartz/dartz.dart';
-import 'package:flowy_logger/flowy_logger.dart';
-import 'package:flowy_sdk/dispatch/flowy_error.dart';
 import 'package:flowy_sdk/protobuf/ffi_response.pb.dart';
 import 'package:isolates/isolates.dart';
 import 'package:isolates/ports.dart';
@@ -14,6 +12,8 @@ import 'package:flowy_sdk/ffi/ffi.dart' as ffi;
 import 'package:flowy_sdk/protobuf.dart';
 import 'package:protobuf/protobuf.dart';
 
+import 'error.dart';
+
 part 'code_gen.dart';
 
 enum FFIException {
@@ -98,29 +98,3 @@ Either<Uint8List, FlowyError> paramsToBytes<T extends GeneratedMessage>(
     return right(FlowyError.fromError('${e.runtimeType}. Stack trace: $s'));
   }
 }
-
-class StackTraceError {
-  Object error;
-  StackTrace trace;
-  StackTraceError(
-    this.error,
-    this.trace,
-  );
-
-  FlowyError toFlowyError() {
-    Log.error('${error.runtimeType}\n');
-    Log.error('Stack trace \n $trace');
-    return FlowyError.fromError('${error.runtimeType}. Stack trace: $trace');
-  }
-
-  String toString() {
-    return '${error.runtimeType}. Stack trace: $trace';
-  }
-}
-
-FFIResponse error_response(FFIRequest request, StackTraceError error) {
-  var response = FFIResponse();
-  response.code = FFIStatusCode.Err;
-  response.error = error.toString();
-  return response;
-}

+ 0 - 35
app_flowy/packages/flowy_sdk/lib/dispatch/flowy_error.dart

@@ -1,35 +0,0 @@
-import '../protobuf/ffi_response.pb.dart';
-
-class FlowyError {
-  late FFIStatusCode _statusCode;
-  late String _error;
-
-  FFIStatusCode get statusCode {
-    return _statusCode;
-  }
-
-  String get error {
-    return _error;
-  }
-
-  bool get has_error {
-    return _statusCode != FFIStatusCode.Ok;
-  }
-
-  String toString() {
-    return "$_statusCode: $_error";
-  }
-
-  FlowyError({required FFIStatusCode statusCode, required String error}) {
-    _statusCode = statusCode;
-    _error = error;
-  }
-
-  factory FlowyError.from(FFIResponse resp) {
-    return FlowyError(statusCode: resp.code, error: resp.error);
-  }
-
-  factory FlowyError.fromError(String error) {
-    return FlowyError(statusCode: FFIStatusCode.Err, error: error);
-  }
-}

+ 1 - 1
app_flowy/packages/flowy_sdk/lib/flowy_sdk.dart

@@ -3,9 +3,9 @@ export 'package:async/async.dart';
 import 'dart:io';
 import 'dart:async';
 import 'package:dartz/dartz.dart';
-import 'package:flowy_sdk/dispatch/flowy_error.dart';
 import 'package:flutter/services.dart';
 import 'dart:ffi';
+import 'dispatch/error.dart';
 import 'ffi/ffi.dart' as ffi;
 import 'package:ffi/ffi.dart';
 

+ 4 - 0
doc/architecture.md

@@ -7,8 +7,12 @@
 
 ## 🎯 Goals of the System
 
+
+
 ## 🤔 Some Design Considerations
+
 ## 📜 High Level Design
+
 ## 📚 Component Design
     
 ### 📕 Component 1

+ 1 - 1
rust-lib/Cargo.toml

@@ -1,6 +1,6 @@
 [workspace]
 members = [
-  "flowy-sys",
+  "flowy-dispatch",
   "flowy-sdk",
   "dart-ffi",
   "flowy-log",

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

@@ -25,7 +25,7 @@ log = "0.4.14"
 serde = { version = "1.0", features = ["derive"] }
 serde_json = {version = "1.0"}
 
-flowy-sys = {path = "../flowy-sys"}
+flowy-dispatch = {path = "../flowy-dispatch"}
 flowy-sdk = {path = "../flowy-sdk"}
 flowy-derive = {path = "../flowy-derive"}
 

+ 2 - 2
rust-lib/dart-ffi/src/lib.rs

@@ -7,8 +7,8 @@ use crate::{
     c::{extend_front_four_bytes_into_bytes, forget_rust},
     model::{FFIRequest, FFIResponse},
 };
+use flowy_dispatch::prelude::*;
 use flowy_sdk::*;
-use flowy_sys::prelude::*;
 use lazy_static::lazy_static;
 use std::{ffi::CStr, os::raw::c_char};
 
@@ -65,7 +65,7 @@ pub extern "C" fn sync_command(input: *const u8, len: usize) -> *const u8 {
 #[no_mangle]
 pub extern "C" fn link_me_please() {}
 
-use flowy_sys::prelude::ToBytes;
+use flowy_dispatch::prelude::ToBytes;
 #[inline(always)]
 async fn post_to_flutter(response: EventResponse, port: i64) {
     let isolate = allo_isolate::Isolate::new(port);

+ 1 - 1
rust-lib/dart-ffi/src/model/ffi_request.rs

@@ -1,5 +1,5 @@
 use flowy_derive::ProtoBuf;
-use flowy_sys::prelude::ModuleRequest;
+use flowy_dispatch::prelude::ModuleRequest;
 use std::convert::TryFrom;
 
 #[derive(Default, ProtoBuf)]

+ 1 - 1
rust-lib/dart-ffi/src/model/ffi_response.rs

@@ -1,5 +1,5 @@
 use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
-use flowy_sys::prelude::{EventResponse, Payload, StatusCode};
+use flowy_dispatch::prelude::{EventResponse, Payload, StatusCode};
 
 #[derive(ProtoBuf_Enum, Clone, Copy)]
 pub enum FFIStatusCode {

+ 1 - 1
rust-lib/flowy-sys/Cargo.toml → rust-lib/flowy-dispatch/Cargo.toml

@@ -1,5 +1,5 @@
 [package]
-name = "flowy-sys"
+name = "flowy-dispatch"
 version = "0.1.0"
 edition = "2018"
 

+ 0 - 0
rust-lib/flowy-sys/src/data.rs → rust-lib/flowy-dispatch/src/data.rs


+ 6 - 23
rust-lib/flowy-sys/src/dispatch.rs → rust-lib/flowy-dispatch/src/dispatch.rs

@@ -28,7 +28,7 @@ impl EventDispatch {
         F: FnOnce() -> Vec<Module>,
     {
         let modules = module_factory();
-        log::debug!("{}", module_info(&modules));
+        log::trace!("{}", module_info(&modules));
         let module_map = as_module_map(modules);
         let runtime = tokio_default_runtime().unwrap();
         let dispatch = EventDispatch {
@@ -50,11 +50,7 @@ impl EventDispatch {
                 let dispatch = dispatch.as_ref().unwrap();
                 let module_map = dispatch.module_map.clone();
                 let service = Box::new(DispatchService { module_map });
-                log::trace!(
-                    "{}: dispatch {:?} to runtime",
-                    &request.id(),
-                    &request.event()
-                );
+                log::trace!("Async event: {:?}", &request.event());
                 let service_ctx = DispatchContext {
                     request,
                     callback: Some(Box::new(callback)),
@@ -77,8 +73,8 @@ impl EventDispatch {
             },
 
             Err(e) => {
-                let msg = format!("Dispatch runtime error: {:?}", e);
-                log::trace!("{}", msg);
+                let msg = format!("EVENT_DISPATCH read failed. {:?}", e);
+                log::error!("{}", msg);
                 DispatchFuture {
                     fut: Box::pin(async { InternalError::new(msg).as_response() }),
                 }
@@ -88,11 +84,7 @@ impl EventDispatch {
 
     pub fn sync_send(request: ModuleRequest) -> EventResponse {
         futures::executor::block_on(async {
-            EventDispatch::async_send(request, |response| {
-                dbg!(&response);
-                Box::pin(async {})
-            })
-            .await
+            EventDispatch::async_send(request, |_| Box::pin(async {})).await
         })
     }
 }
@@ -154,20 +146,11 @@ impl Service<DispatchContext> for DispatchService {
                 match module_map.get(&request.event()) {
                     Some(module) => {
                         let fut = module.new_service(());
-                        log::trace!(
-                            "{}: handle event: {:?} by {}",
-                            request.id(),
-                            request.event(),
-                            module.name
-                        );
                         let service_fut = fut.await?.call(request);
                         service_fut.await
                     },
                     None => {
-                        let msg = format!(
-                            "Can not find the module to handle the request:{:?}",
-                            request
-                        );
+                        let msg = format!("Can not find the event handler. {:?}", request);
                         log::trace!("{}", msg);
                         Err(InternalError::new(msg).into())
                     },

+ 0 - 0
rust-lib/flowy-sys/src/error/error.rs → rust-lib/flowy-dispatch/src/error/error.rs


+ 0 - 0
rust-lib/flowy-sys/src/error/mod.rs → rust-lib/flowy-dispatch/src/error/mod.rs


+ 1 - 2
rust-lib/flowy-sys/src/lib.rs → rust-lib/flowy-dispatch/src/lib.rs

@@ -4,7 +4,6 @@ mod error;
 mod module;
 mod request;
 mod response;
-mod rt;
 mod service;
 mod util;
 
@@ -13,5 +12,5 @@ mod dispatch;
 mod system;
 
 pub mod prelude {
-    pub use crate::{data::*, dispatch::*, error::*, module::*, request::*, response::*, rt::*};
+    pub use crate::{data::*, dispatch::*, error::*, module::*, request::*, response::*};
 }

+ 0 - 0
rust-lib/flowy-sys/src/module/container.rs → rust-lib/flowy-dispatch/src/module/container.rs


+ 0 - 0
rust-lib/flowy-sys/src/module/data.rs → rust-lib/flowy-dispatch/src/module/data.rs


+ 0 - 0
rust-lib/flowy-sys/src/module/mod.rs → rust-lib/flowy-dispatch/src/module/mod.rs


+ 0 - 0
rust-lib/flowy-sys/src/module/module.rs → rust-lib/flowy-dispatch/src/module/module.rs


+ 0 - 0
rust-lib/flowy-sys/src/request/mod.rs → rust-lib/flowy-dispatch/src/request/mod.rs


+ 0 - 0
rust-lib/flowy-sys/src/request/payload.rs → rust-lib/flowy-dispatch/src/request/payload.rs


+ 0 - 0
rust-lib/flowy-sys/src/request/request.rs → rust-lib/flowy-dispatch/src/request/request.rs


+ 0 - 0
rust-lib/flowy-sys/src/response/builder.rs → rust-lib/flowy-dispatch/src/response/builder.rs


+ 0 - 0
rust-lib/flowy-sys/src/response/mod.rs → rust-lib/flowy-dispatch/src/response/mod.rs


+ 0 - 0
rust-lib/flowy-sys/src/response/responder.rs → rust-lib/flowy-dispatch/src/response/responder.rs


+ 0 - 0
rust-lib/flowy-sys/src/response/response.rs → rust-lib/flowy-dispatch/src/response/response.rs


+ 0 - 0
rust-lib/flowy-sys/src/service/boxed.rs → rust-lib/flowy-dispatch/src/service/boxed.rs


+ 0 - 0
rust-lib/flowy-sys/src/service/handler.rs → rust-lib/flowy-dispatch/src/service/handler.rs


+ 0 - 0
rust-lib/flowy-sys/src/service/mod.rs → rust-lib/flowy-dispatch/src/service/mod.rs


+ 0 - 0
rust-lib/flowy-sys/src/service/service.rs → rust-lib/flowy-dispatch/src/service/service.rs


+ 35 - 4
rust-lib/flowy-sys/src/system.rs → rust-lib/flowy-dispatch/src/system.rs

@@ -1,7 +1,4 @@
-use crate::{
-    module::{as_module_map, Module, ModuleMap},
-    rt::Runtime,
-};
+use crate::module::{as_module_map, Module, ModuleMap};
 use futures_core::{ready, task::Context};
 use std::{cell::RefCell, fmt::Debug, future::Future, io, sync::Arc};
 use tokio::{
@@ -127,3 +124,37 @@ impl SystemRunner {
         self
     }
 }
+
+use crate::util::tokio_default_runtime;
+use tokio::{runtime, task::LocalSet};
+
+#[derive(Debug)]
+pub struct Runtime {
+    local: LocalSet,
+    rt: runtime::Runtime,
+}
+
+impl Runtime {
+    pub fn new() -> io::Result<Runtime> {
+        let rt = tokio_default_runtime()?;
+        Ok(Runtime {
+            rt,
+            local: LocalSet::new(),
+        })
+    }
+
+    pub fn spawn<F>(&self, future: F) -> &Self
+    where
+        F: Future<Output = ()> + 'static,
+    {
+        self.local.spawn_local(future);
+        self
+    }
+
+    pub fn block_on<F>(&self, f: F) -> F::Output
+    where
+        F: Future + 'static,
+    {
+        self.local.block_on(&self.rt, f)
+    }
+}

+ 0 - 0
rust-lib/flowy-sys/src/util/mod.rs → rust-lib/flowy-dispatch/src/util/mod.rs


+ 0 - 0
rust-lib/flowy-sys/src/util/ready.rs → rust-lib/flowy-dispatch/src/util/ready.rs


+ 2 - 2
rust-lib/flowy-sys/tests/api/helper.rs → rust-lib/flowy-dispatch/tests/api/helper.rs

@@ -1,11 +1,11 @@
-use flowy_sys::prelude::*;
+use flowy_dispatch::prelude::*;
 use std::sync::Once;
 
 #[allow(dead_code)]
 pub fn setup_env() {
     static INIT: Once = Once::new();
     INIT.call_once(|| {
-        std::env::set_var("RUST_LOG", "flowy_sys=debug,debug");
+        std::env::set_var("RUST_LOG", "flowy_dispatch=debug,debug");
         env_logger::init();
     });
 }

+ 0 - 0
rust-lib/flowy-sys/tests/api/main.rs → rust-lib/flowy-dispatch/tests/api/main.rs


+ 1 - 1
rust-lib/flowy-sys/tests/api/module.rs → rust-lib/flowy-dispatch/tests/api/module.rs

@@ -1,5 +1,5 @@
 use crate::helper::*;
-use flowy_sys::prelude::*;
+use flowy_dispatch::prelude::*;
 
 pub async fn hello() -> String { "say hello".to_string() }
 

+ 1 - 1
rust-lib/flowy-sdk/Cargo.toml

@@ -6,7 +6,7 @@ edition = "2018"
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
-flowy-sys = { path = "../flowy-sys", features = ["use_tracing"]}
+flowy-dispatch = { path = "../flowy-dispatch", features = ["use_tracing"]}
 flowy-log = { path = "../flowy-log", features = ["use_bunyan"] }
 flowy-user = { path = "../flowy-user" }
 tracing = { version = "0.1" }

+ 1 - 1
rust-lib/flowy-sdk/src/lib.rs

@@ -1,7 +1,7 @@
 pub mod module;
 pub use module::*;
 
-use flowy_sys::prelude::*;
+use flowy_dispatch::prelude::*;
 use module::build_modules;
 pub struct FlowySDK {}
 

+ 1 - 1
rust-lib/flowy-sdk/src/module.rs

@@ -1,3 +1,3 @@
-use flowy_sys::prelude::Module;
+use flowy_dispatch::prelude::Module;
 
 pub fn build_modules() -> Vec<Module> { vec![flowy_user::module::create()] }

+ 0 - 4
rust-lib/flowy-sys/src/rt/mod.rs

@@ -1,4 +0,0 @@
-pub use runtime::*;
-
-pub use crate::system::*;
-pub mod runtime;

+ 0 - 34
rust-lib/flowy-sys/src/rt/runtime.rs

@@ -1,34 +0,0 @@
-use crate::util::tokio_default_runtime;
-use std::{future::Future, io};
-use tokio::{runtime, task::LocalSet};
-
-#[derive(Debug)]
-pub struct Runtime {
-    local: LocalSet,
-    rt: runtime::Runtime,
-}
-
-impl Runtime {
-    pub fn new() -> io::Result<Runtime> {
-        let rt = tokio_default_runtime()?;
-        Ok(Runtime {
-            rt,
-            local: LocalSet::new(),
-        })
-    }
-
-    pub fn spawn<F>(&self, future: F) -> &Self
-    where
-        F: Future<Output = ()> + 'static,
-    {
-        self.local.spawn_local(future);
-        self
-    }
-
-    pub fn block_on<F>(&self, f: F) -> F::Output
-    where
-        F: Future + 'static,
-    {
-        self.local.block_on(&self.rt, f)
-    }
-}

+ 1 - 1
rust-lib/flowy-test/Cargo.toml

@@ -7,7 +7,7 @@ edition = "2018"
 
 [dependencies]
 flowy-sdk = { path = "../flowy-sdk"}
-flowy-sys = { path = "../flowy-sys"}
+flowy-dispatch = { path = "../flowy-dispatch"}
 
 serde = { version = "1.0", features = ["derive"] }
 bincode = { version = "1.3"}

+ 2 - 2
rust-lib/flowy-test/src/lib.rs

@@ -1,5 +1,5 @@
+use flowy_dispatch::prelude::*;
 pub use flowy_sdk::*;
-use flowy_sys::prelude::*;
 use std::{
     convert::TryFrom,
     fmt::{Debug, Display},
@@ -11,7 +11,7 @@ use std::{
 
 pub mod prelude {
     pub use crate::EventTester;
-    pub use flowy_sys::prelude::*;
+    pub use flowy_dispatch::prelude::*;
     pub use std::convert::TryFrom;
 }
 

+ 1 - 1
rust-lib/flowy-user/Cargo.toml

@@ -7,7 +7,7 @@ edition = "2018"
 
 [dependencies]
 derive_more = {version = "0.99", features = ["display"]}
-flowy-sys = { path = "../flowy-sys" }
+flowy-dispatch = { path = "../flowy-dispatch" }
 flowy-log = { path = "../flowy-log" }
 flowy-derive = { path = "../flowy-derive" }
 tracing = { version = "0.1", features = ["log"] }

+ 1 - 1
rust-lib/flowy-user/src/handlers/auth.rs

@@ -1,5 +1,5 @@
 use crate::domain::user::*;
-use flowy_sys::prelude::*;
+use flowy_dispatch::prelude::*;
 use std::convert::TryInto;
 
 // tracing instrument 👉🏻 https://docs.rs/tracing/0.1.26/tracing/attr.instrument.html

+ 1 - 1
rust-lib/flowy-user/src/module.rs

@@ -1,5 +1,5 @@
 use crate::{domain::event::UserEvent, handlers::*};
-use flowy_sys::prelude::*;
+use flowy_dispatch::prelude::*;
 
 pub fn create() -> Module {
     Module::new()

+ 0 - 1
scripts/makefile/desktop.toml

@@ -16,7 +16,6 @@ condition = { env_true = ["RELEASE"] }
 env = { DESKTOP_TARGET = "x86_64-apple-darwin" }
 private = true
 run_task = "desktop-build"
-
 [tasks.desktop-build]
 category = "Build"
 condition = { platforms = ["mac"], env_true = ["DEV"] }

+ 0 - 81
scripts/makefile/tool.toml

@@ -1,81 +0,0 @@
-[tasks.rust_env_setup]
-dependencies = ["rustup", "add_targets", "rust_tools"]
-description = "Setup the rust env"
-
-[tasks.rustup]
-script = [
-  """
-  sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
-	curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly -y
-	echo 'export PATH="$$HOME/.cargo/bin:$$PATH"' >> ~/.bash_profile
-	source ~/.bash_profile
-  """,
-]
-script_runner = "@shell"
-
-[tasks.add_compile_targets]
-script = [
-  """
-  rustup target add aarch64-linux-android
-  rustup target add arm-linux-androideabi
-  rustup target add armv7-linux-androideabi
-  rustup target add i686-linux-android
-  rustup target add aarch64-apple-ios
-  rustup target add x86_64-apple-ios
-  rustup target add x86_64-apple-darwin
-  """,
-]
-script_runner = "@shell"
-
-[tasks.rust_tools]
-script = [
-  """
-  # cargo install clog-cli --force
-#  cargo install cargo-cache
-  rustup component add rustfmt
-  cargo install ripgrep
-  cargo install rusty-hook
-  cargo install cargo-expand
-  """,
-]
-script_runner = "@shell"
-
-[tasks.fmt]
-args = ["fmt", "--", "--emit=files"]
-command = "cargo"
-install_crate = "rustfmt"
-[tasks.rust_commit_hook]
-script = [
-  """
-  manifest_path=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/scripts/tool/rust-tool/Cargo.toml
-  cargo run --manifest-path ${manifest_path} hook --commit --path=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib
-  """,
-]
-script_runner = "@shell"
-
-[tasks.reset_db]
-script = [
-  """
-  tool=${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/scripts/tool/rust-tool/Cargo.toml
-  cargo run --manifest-path ${tool} db --reset
-  """,
-]
-script_runner = "@shell"
-
-[tasks.plantuml]
-script = ["""
-  brew cask install java
-  brew install graphviz
-  """]
-script_runner = "@shell"
-
-# For the system Java wrappers to find this JDK, symlink it with
-#   sudo ln -sfn /Users/weidongfu/Documents/tools/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
-# This is a beta version of openjdk for Apple Silicon
-# (openjdk 16 preview).
-
-# openjdk is keg-only, which means it was not symlinked into /Users/weidongfu/Documents/tools/homebrew,
-# because it shadows the macOS `java` wrapper.
-
-# If you need to have openjdk first in your PATH run:
-#   echo 'export PATH="/Users/weidongfu/Documents/tools/homebrew/opt/openjdk/bin:$PATH"' >> ~/.zshrc