From 62303710205978dc30c8af187eb754e62828d7d3 Mon Sep 17 00:00:00 2001 From: frelodev Date: Fri, 29 Dec 2023 01:06:28 +0100 Subject: [PATCH] feat: fixed proto and tonic includes Co-authored-by: zaaarf Co-authored-by: alemi --- build.rs | 12 +++++++----- proto/buffer_service.proto | 2 +- proto/{model => }/cursor.proto | 6 +++--- proto/cursor_service.proto | 10 +++++----- proto/{model => }/files.proto | 0 proto/model/workspace.proto | 0 proto/{model => }/user.proto | 2 +- proto/workspace_service.proto | 14 ++++++++------ src/lib.rs | 12 ++++++------ 9 files changed, 31 insertions(+), 27 deletions(-) rename proto/{model => }/cursor.proto (84%) rename proto/{model => }/files.proto (100%) delete mode 100644 proto/model/workspace.proto rename proto/{model => }/user.proto (81%) diff --git a/build.rs b/build.rs index a33719e..ae01fed 100644 --- a/build.rs +++ b/build.rs @@ -1,15 +1,17 @@ fn main() -> Result<(), Box> { tonic_build::configure() - .build_server(false) + // .build_client(cfg!(feature = "client")) + //.build_server(cfg!(feature = "server")) // FIXME if false, build fails???? + // .build_transport(cfg!(feature = "transport")) .compile( &[ - "proto/model/cursor.proto", - "proto/model/user.proto", + "proto/user.proto", + "proto/cursor.proto", "proto/buffer_service.proto", "proto/cursor_service.proto", "proto/workspace_service.proto" ], - &["proto", "proto", "proto","proto", "proto"] - )?; + &["proto"] + )?; Ok(()) } \ No newline at end of file diff --git a/proto/buffer_service.proto b/proto/buffer_service.proto index 6b09fd0..96ea355 100644 --- a/proto/buffer_service.proto +++ b/proto/buffer_service.proto @@ -1,6 +1,6 @@ syntax = "proto2"; -package codemp.buffer_service; +package buffer_service; // handle buffer changes, keep in sync users service Buffer { diff --git a/proto/model/cursor.proto b/proto/cursor.proto similarity index 84% rename from proto/model/cursor.proto rename to proto/cursor.proto index 1f2ddb1..2c4ea18 100644 --- a/proto/model/cursor.proto +++ b/proto/cursor.proto @@ -1,8 +1,8 @@ syntax = "proto2"; -package codemp.model.cursor; +package cursor; -import "model/user.proto"; +import "user.proto"; // empty request message MovedResponse {} @@ -26,7 +26,7 @@ message CursorPosition { // cursor event, with user id and cursor position message CursorEvent { // user moving the cursor - required codemp.model.user.UserIdentity user = 1; + required user.UserIdentity user = 1; // new cursor position required CursorPosition position = 2; } \ No newline at end of file diff --git a/proto/cursor_service.proto b/proto/cursor_service.proto index cdeb88d..088add5 100644 --- a/proto/cursor_service.proto +++ b/proto/cursor_service.proto @@ -1,13 +1,13 @@ syntax = "proto2"; -package codemp.cursor_service; -import "model/cursor.proto"; -import "model/user.proto"; +package cursor_service; +import "cursor.proto"; +import "user.proto"; // handle cursor events and broadcast to all users service Cursor { // send cursor movement to server - rpc Moved (codemp.model.cursor.CursorEvent) returns (codemp.model.cursor.MovedResponse); + rpc Moved (cursor.CursorEvent) returns (cursor.MovedResponse); // attach to a workspace and receive cursor events - rpc Listen (codemp.model.user.UserIdentity) returns (stream codemp.model.cursor.CursorEvent); + rpc Listen (user.UserIdentity) returns (stream cursor.CursorEvent); } diff --git a/proto/model/files.proto b/proto/files.proto similarity index 100% rename from proto/model/files.proto rename to proto/files.proto diff --git a/proto/model/workspace.proto b/proto/model/workspace.proto deleted file mode 100644 index e69de29..0000000 diff --git a/proto/model/user.proto b/proto/user.proto similarity index 81% rename from proto/model/user.proto rename to proto/user.proto index 4cb0f78..f639f8c 100644 --- a/proto/model/user.proto +++ b/proto/user.proto @@ -1,6 +1,6 @@ syntax = "proto2"; -package codemp.model.user; +package user; // payload identifying user diff --git a/proto/workspace_service.proto b/proto/workspace_service.proto index feffa91..6ed7c93 100644 --- a/proto/workspace_service.proto +++ b/proto/workspace_service.proto @@ -24,8 +24,8 @@ syntax = "proto2"; -package codemp.workspace_service; -import "model/user.proto"; +package workspace_service; +import "user.proto"; message Empty {} @@ -37,7 +37,7 @@ message WorkspaceFileTree { } message WorkspaceUserList { - repeated codemp.model.user.UserIdentity user = 1; + repeated user.UserIdentity user = 1; } message WorkspaceMessage { @@ -65,6 +65,8 @@ service Workspace { rpc Join (JoinRequest) returns (Token); + rpc Delete (BufferPayload) returns (Empty); //deletes buffer + } @@ -102,7 +104,7 @@ enum UserEventType { } message UserEvent { - required codemp.model.user.UserIdentity user = 1; + required user.UserIdentity user = 1; required UserEventType type = 2; } @@ -114,7 +116,7 @@ message BufferPayload { required string path = 1; // user id that is requesting the operation - required codemp.model.user.UserIdentity user = 2; + required user.UserIdentity user = 2; } @@ -132,5 +134,5 @@ message BufferTree{ } message UserList{ - repeated codemp.model.user.UserIdentity users = 1; + repeated user.UserIdentity users = 1; } \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index f45287a..5f27327 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -162,14 +162,14 @@ pub mod prelude; pub use woot; /// protocol types and services auto-generated by grpc -#[cfg(feature = "proto")] +#[cfg(feature = "transport")] #[allow(non_snake_case)] pub mod proto { - tonic::include_proto!("codemp.model.cursor"); - tonic::include_proto!("codemp.model.user"); - tonic::include_proto!("codemp.buffer_service"); - tonic::include_proto!("codemp.cursor_service"); - tonic::include_proto!("codemp.workspace_service"); + pub mod user { tonic::include_proto!("user"); } + pub mod cursor { tonic::include_proto!("cursor"); } + pub mod buffer_service { tonic::include_proto!("buffer_service"); } + pub mod cursor_service { tonic::include_proto!("cursor_service"); } + pub mod workspace_service { tonic::include_proto!("workspace_service"); } }