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
rename flowy-sys to flowy-dispatch
appflowy53a041b6cd14
diff --git a/.idea/appflowy_client.iml b/.idea/appflowy_client.imlindex 2f29ad0a6f..2afc7ac296 100644--- a/.idea/appflowy_client.iml+++ b/.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" />diff --git a/app_flowy/packages/flowy_sdk/lib/dispatch/code_gen.dart b/app_flowy/packages/flowy_sdk/lib/dispatch/code_gen.dartindex 1337498e51..ee9cd8a9b6 100644--- a/app_flowy/packages/flowy_sdk/lib/dispatch/code_gen.dart+++ b/app_flowy/packages/flowy_sdk/lib/dispatch/code_gen.dart@@ -1,46 +1,48 @@++/// Auto gen code from rust ast, do not editpart 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)),+ );+ }}+diff --git a/app_flowy/packages/flowy_sdk/lib/dispatch/dispatch.dart b/app_flowy/packages/flowy_sdk/lib/dispatch/dispatch.dartindex b96b8fdb43..4b44ab4676 100644--- a/app_flowy/packages/flowy_sdk/lib/dispatch/dispatch.dart+++ b/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;-}diff --git a/app_flowy/packages/flowy_sdk/lib/dispatch/flowy_error.dart b/app_flowy/packages/flowy_sdk/lib/dispatch/flowy_error.dartdeleted file mode 100644index a0d0f2ed80..0000000000--- a/app_flowy/packages/flowy_sdk/lib/dispatch/flowy_error.dart+++ /dev/null@@ -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);- }-}diff --git a/app_flowy/packages/flowy_sdk/lib/flowy_sdk.dart b/app_flowy/packages/flowy_sdk/lib/flowy_sdk.dartindex 16e95d7cd1..7abbabe9a4 100644--- a/app_flowy/packages/flowy_sdk/lib/flowy_sdk.dart+++ b/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';diff --git a/doc/architecture.md b/doc/architecture.mdindex 0ee467a873..ddac0254f5 100644--- a/doc/architecture.md+++ b/doc/architecture.md@@ -7,8 +7,12 @@## π― Goals of the System++## π€ Some Design Considerations+## π High Level Design+## π Component Design### π Component 1diff --git a/rust-lib/Cargo.toml b/rust-lib/Cargo.tomlindex 072d81dbfb..8fb1e8ac2a 100644--- a/rust-lib/Cargo.toml+++ b/rust-lib/Cargo.toml@@ -1,6 +1,6 @@[workspace]members = [- "flowy-sys",+ "flowy-dispatch","flowy-sdk","dart-ffi","flowy-log",diff --git a/rust-lib/dart-ffi/Cargo.toml b/rust-lib/dart-ffi/Cargo.tomlindex 84aafb0533..7373739538 100644--- a/rust-lib/dart-ffi/Cargo.toml+++ b/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"}diff --git a/rust-lib/dart-ffi/src/lib.rs b/rust-lib/dart-ffi/src/lib.rsindex 18d51dab56..08273a60ae 100644--- a/rust-lib/dart-ffi/src/lib.rs+++ b/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);diff --git a/rust-lib/dart-ffi/src/model/ffi_request.rs b/rust-lib/dart-ffi/src/model/ffi_request.rsindex 4fa9900cd8..e9c2295d47 100644--- a/rust-lib/dart-ffi/src/model/ffi_request.rs+++ b/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)]diff --git a/rust-lib/dart-ffi/src/model/ffi_response.rs b/rust-lib/dart-ffi/src/model/ffi_response.rsindex 28df58ee44..97cc2395a5 100644--- a/rust-lib/dart-ffi/src/model/ffi_response.rs+++ b/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 {diff --git a/rust-lib/flowy-sys/Cargo.toml b/rust-lib/flowy-dispatch/Cargo.tomlsimilarity index 97%rename from rust-lib/flowy-sys/Cargo.tomlrename to rust-lib/flowy-dispatch/Cargo.tomlindex e337c64c28..ed459fe902 100644--- a/rust-lib/flowy-sys/Cargo.toml+++ b/rust-lib/flowy-dispatch/Cargo.toml@@ -1,5 +1,5 @@[package]-name = "flowy-sys"+name = "flowy-dispatch"version = "0.1.0"edition = "2018"diff --git a/rust-lib/flowy-sys/src/data.rs b/rust-lib/flowy-dispatch/src/data.rssimilarity index 100%rename from rust-lib/flowy-sys/src/data.rsrename to rust-lib/flowy-dispatch/src/data.rsdiff --git a/rust-lib/flowy-sys/src/dispatch.rs b/rust-lib/flowy-dispatch/src/dispatch.rssimilarity index 85%rename from rust-lib/flowy-sys/src/dispatch.rsrename to rust-lib/flowy-dispatch/src/dispatch.rsindex f6a07b20ff..48dd0da420 100644--- a/rust-lib/flowy-sys/src/dispatch.rs+++ b/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())},diff --git a/rust-lib/flowy-sys/src/error/error.rs b/rust-lib/flowy-dispatch/src/error/error.rssimilarity index 100%rename from rust-lib/flowy-sys/src/error/error.rsrename to rust-lib/flowy-dispatch/src/error/error.rsdiff --git a/rust-lib/flowy-sys/src/error/mod.rs b/rust-lib/flowy-dispatch/src/error/mod.rssimilarity index 100%rename from rust-lib/flowy-sys/src/error/mod.rsrename to rust-lib/flowy-dispatch/src/error/mod.rsdiff --git a/rust-lib/flowy-sys/src/lib.rs b/rust-lib/flowy-dispatch/src/lib.rssimilarity index 84%rename from rust-lib/flowy-sys/src/lib.rsrename to rust-lib/flowy-dispatch/src/lib.rsindex 71cdcaa15a..0b282287f5 100644--- a/rust-lib/flowy-sys/src/lib.rs+++ b/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::*};}diff --git a/rust-lib/flowy-sys/src/module/container.rs b/rust-lib/flowy-dispatch/src/module/container.rssimilarity index 100%rename from rust-lib/flowy-sys/src/module/container.rsrename to rust-lib/flowy-dispatch/src/module/container.rsdiff --git a/rust-lib/flowy-sys/src/module/data.rs b/rust-lib/flowy-dispatch/src/module/data.rssimilarity index 100%rename from rust-lib/flowy-sys/src/module/data.rsrename to rust-lib/flowy-dispatch/src/module/data.rsdiff --git a/rust-lib/flowy-sys/src/module/mod.rs b/rust-lib/flowy-dispatch/src/module/mod.rssimilarity index 100%rename from rust-lib/flowy-sys/src/module/mod.rsrename to rust-lib/flowy-dispatch/src/module/mod.rsdiff --git a/rust-lib/flowy-sys/src/module/module.rs b/rust-lib/flowy-dispatch/src/module/module.rssimilarity index 100%rename from rust-lib/flowy-sys/src/module/module.rsrename to rust-lib/flowy-dispatch/src/module/module.rsdiff --git a/rust-lib/flowy-sys/src/request/mod.rs b/rust-lib/flowy-dispatch/src/request/mod.rssimilarity index 100%rename from rust-lib/flowy-sys/src/request/mod.rsrename to rust-lib/flowy-dispatch/src/request/mod.rsdiff --git a/rust-lib/flowy-sys/src/request/payload.rs b/rust-lib/flowy-dispatch/src/request/payload.rssimilarity index 100%rename from rust-lib/flowy-sys/src/request/payload.rsrename to rust-lib/flowy-dispatch/src/request/payload.rsdiff --git a/rust-lib/flowy-sys/src/request/request.rs b/rust-lib/flowy-dispatch/src/request/request.rssimilarity index 100%rename from rust-lib/flowy-sys/src/request/request.rsrename to rust-lib/flowy-dispatch/src/request/request.rsdiff --git a/rust-lib/flowy-sys/src/response/builder.rs b/rust-lib/flowy-dispatch/src/response/builder.rssimilarity index 100%rename from rust-lib/flowy-sys/src/response/builder.rsrename to rust-lib/flowy-dispatch/src/response/builder.rsdiff --git a/rust-lib/flowy-sys/src/response/mod.rs b/rust-lib/flowy-dispatch/src/response/mod.rssimilarity index 100%rename from rust-lib/flowy-sys/src/response/mod.rsrename to rust-lib/flowy-dispatch/src/response/mod.rsdiff --git a/rust-lib/flowy-sys/src/response/responder.rs b/rust-lib/flowy-dispatch/src/response/responder.rssimilarity index 100%rename from rust-lib/flowy-sys/src/response/responder.rsrename to rust-lib/flowy-dispatch/src/response/responder.rsdiff --git a/rust-lib/flowy-sys/src/response/response.rs b/rust-lib/flowy-dispatch/src/response/response.rssimilarity index 100%rename from rust-lib/flowy-sys/src/response/response.rsrename to rust-lib/flowy-dispatch/src/response/response.rsdiff --git a/rust-lib/flowy-sys/src/service/boxed.rs b/rust-lib/flowy-dispatch/src/service/boxed.rssimilarity index 100%rename from rust-lib/flowy-sys/src/service/boxed.rsrename to rust-lib/flowy-dispatch/src/service/boxed.rsdiff --git a/rust-lib/flowy-sys/src/service/handler.rs b/rust-lib/flowy-dispatch/src/service/handler.rssimilarity index 100%rename from rust-lib/flowy-sys/src/service/handler.rsrename to rust-lib/flowy-dispatch/src/service/handler.rsdiff --git a/rust-lib/flowy-sys/src/service/mod.rs b/rust-lib/flowy-dispatch/src/service/mod.rssimilarity index 100%rename from rust-lib/flowy-sys/src/service/mod.rsrename to rust-lib/flowy-dispatch/src/service/mod.rsdiff --git a/rust-lib/flowy-sys/src/service/service.rs b/rust-lib/flowy-dispatch/src/service/service.rssimilarity index 100%rename from rust-lib/flowy-sys/src/service/service.rsrename to rust-lib/flowy-dispatch/src/service/service.rsdiff --git a/rust-lib/flowy-sys/src/system.rs b/rust-lib/flowy-dispatch/src/system.rssimilarity index 82%rename from rust-lib/flowy-sys/src/system.rsrename to rust-lib/flowy-dispatch/src/system.rsindex e8292497f1..ae395c0a0e 100644--- a/rust-lib/flowy-sys/src/system.rs+++ b/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)+ }+}diff --git a/rust-lib/flowy-sys/src/util/mod.rs b/rust-lib/flowy-dispatch/src/util/mod.rssimilarity index 100%rename from rust-lib/flowy-sys/src/util/mod.rsrename to rust-lib/flowy-dispatch/src/util/mod.rsdiff --git a/rust-lib/flowy-sys/src/util/ready.rs b/rust-lib/flowy-dispatch/src/util/ready.rssimilarity index 100%rename from rust-lib/flowy-sys/src/util/ready.rsrename to rust-lib/flowy-dispatch/src/util/ready.rsdiff --git a/rust-lib/flowy-sys/tests/api/helper.rs b/rust-lib/flowy-dispatch/tests/api/helper.rssimilarity index 74%rename from rust-lib/flowy-sys/tests/api/helper.rsrename to rust-lib/flowy-dispatch/tests/api/helper.rsindex 97966e9f70..63f5ae2125 100644--- a/rust-lib/flowy-sys/tests/api/helper.rs+++ b/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();});}diff --git a/rust-lib/flowy-sys/tests/api/main.rs b/rust-lib/flowy-dispatch/tests/api/main.rssimilarity index 100%rename from rust-lib/flowy-sys/tests/api/main.rsrename to rust-lib/flowy-dispatch/tests/api/main.rsdiff --git a/rust-lib/flowy-sys/tests/api/module.rs b/rust-lib/flowy-dispatch/tests/api/module.rssimilarity index 92%rename from rust-lib/flowy-sys/tests/api/module.rsrename to rust-lib/flowy-dispatch/tests/api/module.rsindex 997113e6c2..be6b98ef64 100644--- a/rust-lib/flowy-sys/tests/api/module.rs+++ b/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() }diff --git a/rust-lib/flowy-sdk/Cargo.toml b/rust-lib/flowy-sdk/Cargo.tomlindex c07ffd19c3..088b0effdd 100644--- a/rust-lib/flowy-sdk/Cargo.toml+++ b/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" }diff --git a/rust-lib/flowy-sdk/src/lib.rs b/rust-lib/flowy-sdk/src/lib.rsindex b781d251bd..a78266abb7 100644--- a/rust-lib/flowy-sdk/src/lib.rs+++ b/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 {}diff --git a/rust-lib/flowy-sdk/src/module.rs b/rust-lib/flowy-sdk/src/module.rsindex 229d7227c3..2c5cd39e72 100644--- a/rust-lib/flowy-sdk/src/module.rs+++ b/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()] }diff --git a/rust-lib/flowy-sys/src/rt/mod.rs b/rust-lib/flowy-sys/src/rt/mod.rsdeleted file mode 100644index 4a0fa7d87a..0000000000--- a/rust-lib/flowy-sys/src/rt/mod.rs+++ /dev/null@@ -1,4 +0,0 @@-pub use runtime::*;--pub use crate::system::*;-pub mod runtime;diff --git a/rust-lib/flowy-sys/src/rt/runtime.rs b/rust-lib/flowy-sys/src/rt/runtime.rsdeleted file mode 100644index 428f107e09..0000000000--- a/rust-lib/flowy-sys/src/rt/runtime.rs+++ /dev/null@@ -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)- }-}diff --git a/rust-lib/flowy-test/Cargo.toml b/rust-lib/flowy-test/Cargo.tomlindex d0d1a6f7f3..0fc9680290 100644--- a/rust-lib/flowy-test/Cargo.toml+++ b/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"}diff --git a/rust-lib/flowy-test/src/lib.rs b/rust-lib/flowy-test/src/lib.rsindex 7987e1e5a9..5a8fc4a637 100644--- a/rust-lib/flowy-test/src/lib.rs+++ b/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;}diff --git a/rust-lib/flowy-user/Cargo.toml b/rust-lib/flowy-user/Cargo.tomlindex 4510fadd60..af5a7727d9 100644--- a/rust-lib/flowy-user/Cargo.toml+++ b/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"] }diff --git a/rust-lib/flowy-user/src/handlers/auth.rs b/rust-lib/flowy-user/src/handlers/auth.rsindex b846e439a2..c7d6231208 100644--- a/rust-lib/flowy-user/src/handlers/auth.rs+++ b/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.htmldiff --git a/rust-lib/flowy-user/src/module.rs b/rust-lib/flowy-user/src/module.rsindex 1e46f10d16..94e53ec06f 100644--- a/rust-lib/flowy-user/src/module.rs+++ b/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()diff --git a/scripts/makefile/desktop.toml b/scripts/makefile/desktop.tomlindex 3aee8610b2..47210ddb8f 100644--- a/scripts/makefile/desktop.toml+++ b/scripts/makefile/desktop.toml@@ -16,7 +16,6 @@ condition = { env_true = ["RELEASE"] }env = { DESKTOP_TARGET = "x86_64-apple-darwin" }private = truerun_task = "desktop-build"-[tasks.desktop-build]category = "Build"condition = { platforms = ["mac"], env_true = ["DEV"] }diff --git a/scripts/makefile/tool.toml b/scripts/makefile/tool.tomldeleted file mode 100644index 042dc1542a..0000000000--- a/scripts/makefile/tool.toml+++ /dev/null@@ -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