fix generate pb issues

This commit is contained in:
appflowy 2021-12-04 17:31:32 +08:00
parent c649673b2b
commit 63082418be
27 changed files with 79 additions and 56 deletions

View File

@ -14,12 +14,14 @@ class UserNotification extends $pb.ProtobufEnum {
static const UserNotification UserAuthChanged = UserNotification._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserAuthChanged');
static const UserNotification UserProfileUpdated = UserNotification._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserProfileUpdated');
static const UserNotification UserUnauthorized = UserNotification._(3, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserUnauthorized');
static const UserNotification UserWsConnectStateChanged = UserNotification._(4, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'UserWsConnectStateChanged');
static const $core.List<UserNotification> values = <UserNotification> [
Unknown,
UserAuthChanged,
UserProfileUpdated,
UserUnauthorized,
UserWsConnectStateChanged,
];
static final $core.Map<$core.int, UserNotification> _byValue = $pb.ProtobufEnum.initByValue(values);

View File

@ -16,8 +16,9 @@ const UserNotification$json = const {
const {'1': 'UserAuthChanged', '2': 1},
const {'1': 'UserProfileUpdated', '2': 2},
const {'1': 'UserUnauthorized', '2': 3},
const {'1': 'UserWsConnectStateChanged', '2': 4},
],
};
/// Descriptor for `UserNotification`. Decode as a `google.protobuf.EnumDescriptorProto`.
final $typed_data.Uint8List userNotificationDescriptor = $convert.base64Decode('ChBVc2VyTm90aWZpY2F0aW9uEgsKB1Vua25vd24QABITCg9Vc2VyQXV0aENoYW5nZWQQARIWChJVc2VyUHJvZmlsZVVwZGF0ZWQQAhIUChBVc2VyVW5hdXRob3JpemVkEAM=');
final $typed_data.Uint8List userNotificationDescriptor = $convert.base64Decode('ChBVc2VyTm90aWZpY2F0aW9uEgsKB1Vua25vd24QABITCg9Vc2VyQXV0aENoYW5nZWQQARIWChJVc2VyUHJvZmlsZVVwZGF0ZWQQAhIUChBVc2VyVW5hdXRob3JpemVkEAMSHQoZVXNlcldzQ29ubmVjdFN0YXRlQ2hhbmdlZBAE');

View File

@ -1,2 +1,3 @@
// Auto-generated, do not edit
mod model;
pub use model::*;
pub use model::*;

View File

@ -1,2 +1,3 @@
// Auto-generated, do not edit
mod model;
pub use model::*;
pub use model::*;

View File

@ -1,2 +1,3 @@
// Auto-generated, do not edit
mod model;
pub use model::*;
pub use model::*;

View File

@ -191,14 +191,8 @@ impl ClientDocEditor {
let retry = Retry::spawn(strategy, action);
tokio::spawn(async move {
match retry.await {
Ok(_) => {
//
log::debug!("Notify open doc success");
},
Err(e) => {
//
log::error!("Notify open doc failed: {}", e);
},
Ok(_) => log::debug!("Notify open doc success"),
Err(e) => log::error!("Notify open doc failed: {}", e),
}
});
}
@ -280,6 +274,12 @@ impl ClientDocEditor {
pub struct EditDocWsHandler(pub Arc<ClientDocEditor>);
impl std::ops::Deref for EditDocWsHandler {
type Target = Arc<ClientDocEditor>;
fn deref(&self) -> &Self::Target { &self.0 }
}
impl WsDocumentHandler for EditDocWsHandler {
fn receive(&self, doc_data: WsDocumentData) {
let edit_doc = self.0.clone();
@ -293,7 +293,7 @@ impl WsDocumentHandler for EditDocWsHandler {
fn state_changed(&self, state: &WsState) {
match state {
WsState::Init => {},
WsState::Connected(_) => self.0.notify_open_doc(),
WsState::Connected(_) => self.notify_open_doc(),
WsState::Disconnected(_e) => {},
}
}

View File

@ -1,7 +1,7 @@
mod doc_actor;
mod editor;
mod model;
mod queue;
pub(crate) use doc_actor::*;
pub use editor::*;
pub(crate) use model::*;
pub(crate) use queue::*;

View File

@ -1,7 +1,6 @@
mod deps_resolve;
// mod flowy_server;
pub mod module;
use crate::deps_resolve::WorkspaceDepsResolver;
use backend_service::config::ServerConfig;
use flowy_document::module::FlowyDocument;
@ -63,7 +62,7 @@ pub struct FlowySDK {
config: FlowySDKConfig,
pub user_session: Arc<UserSession>,
pub flowy_document: Arc<FlowyDocument>,
pub workspace: Arc<WorkspaceController>,
pub workspace_ctrl: Arc<WorkspaceController>,
pub dispatcher: Arc<EventDispatcher>,
}
@ -80,16 +79,17 @@ impl FlowySDK {
.build(),
);
let flowy_document = mk_document_module(user_session.clone(), &config.server_config);
let workspace = mk_workspace(user_session.clone(), flowy_document.clone(), &config.server_config);
let modules = mk_modules(workspace.clone(), user_session.clone());
let workspace_ctrl =
mk_workspace_controller(user_session.clone(), flowy_document.clone(), &config.server_config);
let modules = mk_modules(workspace_ctrl.clone(), user_session.clone());
let dispatcher = Arc::new(EventDispatcher::construct(|| modules));
_init(&dispatcher, user_session.clone(), workspace.clone());
_init(&dispatcher, user_session.clone(), workspace_ctrl.clone());
Self {
config,
user_session,
flowy_document,
workspace,
workspace_ctrl,
dispatcher,
}
}
@ -155,12 +155,12 @@ fn init_log(config: &FlowySDKConfig) {
}
}
fn mk_workspace(
fn mk_workspace_controller(
user_session: Arc<UserSession>,
flowy_document: Arc<FlowyDocument>,
server_config: &ServerConfig,
) -> Arc<WorkspaceController> {
let workspace_deps = WorkspaceDepsResolver::new(user_session);
let (user, database) = workspace_deps.split_into();
flowy_workspace::module::mk_workspace(user, database, flowy_document, server_config)
flowy_workspace::module::init_workspace_controller(user, database, flowy_document, server_config)
}

View File

@ -7,7 +7,9 @@ use lib_dispatch::prelude::Module;
use std::sync::Arc;
pub fn mk_modules(workspace_controller: Arc<WorkspaceController>, user_session: Arc<UserSession>) -> Vec<Module> {
vec![mk_user_module(user_session), mk_workspace_module(workspace_controller)]
let user_module = mk_user_module(user_session);
let workspace_module = mk_workspace_module(workspace_controller);
vec![user_module, workspace_module]
}
fn mk_user_module(user_session: Arc<UserSession>) -> Module { flowy_user::module::create(user_session) }

View File

@ -1,3 +1,3 @@
proto_crates = ["src/entities", "src/event.rs", "src/errors.rs", "src/notify"]
proto_crates = ["src/event.rs", "src/errors.rs", "src/notify"]
event_files = ["src/event.rs"]

View File

@ -10,6 +10,7 @@ pub(crate) enum UserNotification {
UserAuthChanged = 1,
UserProfileUpdated = 2,
UserUnauthorized = 3,
UserWsConnectStateChanged = 4,
}
impl std::default::Default for UserNotification {

View File

@ -1,2 +1,3 @@
// Auto-generated, do not edit
mod model;
pub use model::*;
pub use model::*;

View File

@ -29,6 +29,7 @@ pub enum UserNotification {
UserAuthChanged = 1,
UserProfileUpdated = 2,
UserUnauthorized = 3,
UserWsConnectStateChanged = 4,
}
impl ::protobuf::ProtobufEnum for UserNotification {
@ -42,6 +43,7 @@ impl ::protobuf::ProtobufEnum for UserNotification {
1 => ::std::option::Option::Some(UserNotification::UserAuthChanged),
2 => ::std::option::Option::Some(UserNotification::UserProfileUpdated),
3 => ::std::option::Option::Some(UserNotification::UserUnauthorized),
4 => ::std::option::Option::Some(UserNotification::UserWsConnectStateChanged),
_ => ::std::option::Option::None
}
}
@ -52,6 +54,7 @@ impl ::protobuf::ProtobufEnum for UserNotification {
UserNotification::UserAuthChanged,
UserNotification::UserProfileUpdated,
UserNotification::UserUnauthorized,
UserNotification::UserWsConnectStateChanged,
];
values
}
@ -80,19 +83,22 @@ impl ::protobuf::reflect::ProtobufValue for UserNotification {
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x10observable.proto*b\n\x10UserNotification\x12\x0b\n\x07Unknown\x10\
\0\x12\x13\n\x0fUserAuthChanged\x10\x01\x12\x16\n\x12UserProfileUpdated\
\x10\x02\x12\x14\n\x10UserUnauthorized\x10\x03J\xce\x01\n\x06\x12\x04\0\
\0\x07\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x05\0\x12\x04\x02\0\
\x07\x01\n\n\n\x03\x05\0\x01\x12\x03\x02\x05\x15\n\x0b\n\x04\x05\0\x02\0\
\x12\x03\x03\x04\x10\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x03\x04\x0b\n\
\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x03\x0e\x0f\n\x0b\n\x04\x05\0\x02\x01\
\x12\x03\x04\x04\x18\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x04\x04\x13\n\
\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x04\x16\x17\n\x0b\n\x04\x05\0\x02\
\x02\x12\x03\x05\x04\x1b\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\x05\x04\
\x16\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\x05\x19\x1a\n\x0b\n\x04\x05\0\
\x02\x03\x12\x03\x06\x04\x19\n\x0c\n\x05\x05\0\x02\x03\x01\x12\x03\x06\
\x04\x14\n\x0c\n\x05\x05\0\x02\x03\x02\x12\x03\x06\x17\x18b\x06proto3\
\n\x10observable.proto*\x81\x01\n\x10UserNotification\x12\x0b\n\x07Unkno\
wn\x10\0\x12\x13\n\x0fUserAuthChanged\x10\x01\x12\x16\n\x12UserProfileUp\
dated\x10\x02\x12\x14\n\x10UserUnauthorized\x10\x03\x12\x1d\n\x19UserWsC\
onnectStateChanged\x10\x04J\xf7\x01\n\x06\x12\x04\0\0\x08\x01\n\x08\n\
\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x05\0\x12\x04\x02\0\x08\x01\n\n\n\x03\
\x05\0\x01\x12\x03\x02\x05\x15\n\x0b\n\x04\x05\0\x02\0\x12\x03\x03\x04\
\x10\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x03\x04\x0b\n\x0c\n\x05\x05\0\
\x02\0\x02\x12\x03\x03\x0e\x0f\n\x0b\n\x04\x05\0\x02\x01\x12\x03\x04\x04\
\x18\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x04\x04\x13\n\x0c\n\x05\x05\0\
\x02\x01\x02\x12\x03\x04\x16\x17\n\x0b\n\x04\x05\0\x02\x02\x12\x03\x05\
\x04\x1b\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\x05\x04\x16\n\x0c\n\x05\
\x05\0\x02\x02\x02\x12\x03\x05\x19\x1a\n\x0b\n\x04\x05\0\x02\x03\x12\x03\
\x06\x04\x19\n\x0c\n\x05\x05\0\x02\x03\x01\x12\x03\x06\x04\x14\n\x0c\n\
\x05\x05\0\x02\x03\x02\x12\x03\x06\x17\x18\n\x0b\n\x04\x05\0\x02\x04\x12\
\x03\x07\x04\"\n\x0c\n\x05\x05\0\x02\x04\x01\x12\x03\x07\x04\x1d\n\x0c\n\
\x05\x05\0\x02\x04\x02\x12\x03\x07\x20!b\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

View File

@ -5,4 +5,5 @@ enum UserNotification {
UserAuthChanged = 1;
UserProfileUpdated = 2;
UserUnauthorized = 3;
UserWsConnectStateChanged = 4;
}

View File

@ -333,7 +333,7 @@ impl UserSession {
WsState::Disconnected(_) => match ws_controller.retry().await {
Ok(_) => {},
Err(e) => {
log::error!("Retry websocket connect failed: {:?}", e);
log::error!("websocket connect failed: {:?}", e);
},
},
}

View File

@ -28,7 +28,7 @@ pub trait WorkspaceDatabase: Send + Sync {
}
}
pub fn mk_workspace(
pub fn init_workspace_controller(
user: Arc<dyn WorkspaceUser>,
database: Arc<dyn WorkspaceDatabase>,
flowy_document: Arc<FlowyDocument>,

View File

@ -1,2 +1,3 @@
// Auto-generated, do not edit
mod model;
pub use model::*;
pub use model::*;

View File

@ -1,2 +1,3 @@
// Auto-generated, do not edit
mod model;
pub use model::*;
pub use model::*;

View File

@ -53,12 +53,12 @@ fn write_rust_crate_mod_file(crate_infos: &[CrateProtoInfo]) {
{
Ok(ref mut file) => {
let mut mod_file_content = String::new();
mod_file_content.push_str("// Auto-generated, do not edit \n");
mod_file_content.push_str("// Auto-generated, do not edit\n");
walk_dir(
crate_info.inner.proto_file_output_dir().as_ref(),
|e| !e.file_type().is_dir(),
|_, name| {
let c = format!("\nmod {}; \npub use {}::*; \n", &name, &name);
let c = format!("\nmod {};\npub use {}::*;\n", &name, &name);
mod_file_content.push_str(c.as_ref());
},
);

View File

@ -17,10 +17,8 @@ impl CrateProtoInfo {
// mod model;
// pub use model::*;
let mod_file_path = format!("{}/mod.rs", self.inner.protobuf_crate_name());
let content = r#"
mod model;
pub use model::*;
"#;
let mut content = format!("// Auto-generated, do not edit\n");
content.push_str("mod model;\npub use model::*;");
match OpenOptions::new()
.create(true)
.write(true)

View File

@ -28,7 +28,7 @@ script = [
cargo run \
--manifest-path ${flowy_tool} pb-gen \
--rust_sources ${rust_lib},${shared_lib} \
--rust_sources ${rust_lib} ${shared_lib} \
--derive_meta=${derive_meta} \
--flutter_package_lib=${flutter_package_lib}
""",

View File

@ -77,7 +77,8 @@ pub fn category_from_str(type_str: &str) -> TypeCategory {
| "UserToken"
| "UserProfile"
| "UpdateUserRequest"
| "UpdateUserParams" => TypeCategory::Protobuf,
| "UpdateUserParams"
=> TypeCategory::Protobuf,
"WorkspaceEvent"
| "WorkspaceNotification"
| "ErrorCode"
@ -90,7 +91,8 @@ pub fn category_from_str(type_str: &str) -> TypeCategory {
| "ExportType"
| "RevType"
| "WsDataType"
| "WsModule" => TypeCategory::Enum,
| "WsModule"
=> TypeCategory::Enum,
"Option" => TypeCategory::Opt,
_ => TypeCategory::Primitive,

View File

@ -1,2 +1,3 @@
// Auto-generated, do not edit
mod model;
pub use model::*;
pub use model::*;

View File

@ -1,2 +1,3 @@
// Auto-generated, do not edit
mod model;
pub use model::*;
pub use model::*;

View File

@ -1,2 +1,3 @@
// Auto-generated, do not edit
mod model;
pub use model::*;
pub use model::*;

View File

@ -1,2 +1,3 @@
// Auto-generated, do not edit
mod model;
pub use model::*;
pub use model::*;