feat: fixed proto and tonic includes

Co-authored-by: zaaarf <me@zaaarf.foo>
Co-authored-by: alemi <me@alemi.dev>
This commit is contained in:
frelodev 2023-12-29 01:06:28 +01:00
parent 3b1be930d8
commit 6230371020
9 changed files with 31 additions and 27 deletions

View file

@ -1,15 +1,17 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
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(())
}

View file

@ -1,6 +1,6 @@
syntax = "proto2";
package codemp.buffer_service;
package buffer_service;
// handle buffer changes, keep in sync users
service Buffer {

View file

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

View file

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

View file

@ -1,6 +1,6 @@
syntax = "proto2";
package codemp.model.user;
package user;
// payload identifying user

View file

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

View file

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