mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 07:24:52 +01:00
feat: improved protocol definition
use session for authentication, then workspace to keep in sync and subscribe to new buffers. Buffer service will dispatch live updates.
This commit is contained in:
parent
2287793cd9
commit
4491482b0a
3 changed files with 33 additions and 9 deletions
1
build.rs
1
build.rs
|
@ -1,4 +1,5 @@
|
|||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
tonic_build::compile_protos("proto/session.proto")?;
|
||||
tonic_build::compile_protos("proto/workspace.proto")?;
|
||||
tonic_build::compile_protos("proto/buffer.proto")?;
|
||||
Ok(())
|
||||
|
|
17
proto/session.proto
Normal file
17
proto/session.proto
Normal file
|
@ -0,0 +1,17 @@
|
|||
syntax = "proto3";
|
||||
package session;
|
||||
|
||||
service Session {
|
||||
rpc Create (SessionRequest) returns (SessionResponse);
|
||||
rpc Join (SessionRequest) returns (SessionResponse);
|
||||
rpc Leave (SessionRequest) returns (SessionResponse);
|
||||
}
|
||||
|
||||
message SessionRequest {
|
||||
optional string sessionKey = 1;
|
||||
}
|
||||
|
||||
message SessionResponse {
|
||||
string sessionKey = 1;
|
||||
bool accepted = 2;
|
||||
}
|
|
@ -2,20 +2,26 @@ syntax = "proto3";
|
|||
package workspace;
|
||||
|
||||
service Workspace {
|
||||
rpc Create (SessionRequest) returns (SessionResponse);
|
||||
rpc Join (SessionRequest) returns (SessionResponse);
|
||||
rpc Sync (SessionRequest) returns (SessionResponse);
|
||||
rpc Leave (SessionRequest) returns (SessionResponse);
|
||||
rpc Buffers (WorkspaceRequest) returns (BufferList);
|
||||
rpc Push (BufferPayload) returns (WorkspaceResponse);
|
||||
rpc Pull (BufferPayload) returns (BufferPayload);
|
||||
}
|
||||
|
||||
message SessionRequest {
|
||||
message WorkspaceRequest {
|
||||
string sessionKey = 1;
|
||||
optional string content = 2;
|
||||
}
|
||||
|
||||
message SessionResponse {
|
||||
message WorkspaceResponse {
|
||||
string sessionKey = 1;
|
||||
bool accepted = 2;
|
||||
optional string hash = 3;
|
||||
optional string content = 4;
|
||||
}
|
||||
|
||||
message BufferList {
|
||||
repeated string path = 1;
|
||||
}
|
||||
|
||||
message BufferPayload {
|
||||
string sessionKey = 1;
|
||||
string path = 2;
|
||||
optional string content = 3;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue