mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 15:24:48 +01:00
Cleanup of proto
Co-authored-by: alemi.dev <me@alemi.dev>
This commit is contained in:
parent
d14f004f73
commit
3738f7beb4
7 changed files with 70 additions and 99 deletions
|
@ -1,6 +1,7 @@
|
|||
syntax = "proto2";
|
||||
|
||||
package auth_service;
|
||||
package auth;
|
||||
|
||||
|
||||
// authenticates users, issuing tokens
|
||||
service Auth {
|
||||
|
@ -8,10 +9,12 @@ service Auth {
|
|||
rpc Login (WorkspaceJoinRequest) returns (Token);
|
||||
}
|
||||
|
||||
|
||||
message Token {
|
||||
required string token = 1;
|
||||
}
|
||||
|
||||
|
||||
message WorkspaceJoinRequest {
|
||||
required string workspace_id = 1;
|
||||
required string username = 2;
|
|
@ -1,6 +1,6 @@
|
|||
syntax = "proto2";
|
||||
|
||||
package buffer_service;
|
||||
package buffer;
|
||||
|
||||
// handle buffer changes, keep in sync users
|
||||
service Buffer {
|
18
proto/common.proto
Normal file
18
proto/common.proto
Normal file
|
@ -0,0 +1,18 @@
|
|||
syntax = "proto2";
|
||||
|
||||
package common;
|
||||
|
||||
|
||||
// payload identifying user
|
||||
message UserIdentity {
|
||||
// user identifier
|
||||
required string id = 1;
|
||||
}
|
||||
|
||||
message UserList {
|
||||
repeated UserIdentity users = 1;
|
||||
}
|
||||
|
||||
message Empty{
|
||||
//generic Empty message
|
||||
}
|
|
@ -1,8 +1,14 @@
|
|||
syntax = "proto2";
|
||||
|
||||
package cursor;
|
||||
import "common.proto";
|
||||
|
||||
// handle cursor events and broadcast to all users
|
||||
service Cursor {
|
||||
// subscribe to a workspace's cursor events
|
||||
rpc Attach (stream cursor.CursorEvent) returns (stream cursor.CursorEvent);
|
||||
}
|
||||
|
||||
import "user.proto";
|
||||
|
||||
// empty request
|
||||
message MovedResponse {}
|
||||
|
@ -26,7 +32,7 @@ message CursorPosition {
|
|||
// cursor event, with user id and cursor position
|
||||
message CursorEvent {
|
||||
// user moving the cursor
|
||||
required user.UserIdentity user = 1;
|
||||
required common.UserIdentity user = 1;
|
||||
// new cursor position
|
||||
required CursorPosition position = 2;
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
syntax = "proto2";
|
||||
|
||||
package cursor_service;
|
||||
import "cursor.proto";
|
||||
import "user.proto";
|
||||
|
||||
// handle cursor events and broadcast to all users
|
||||
service Cursor {
|
||||
// subscribe to a workspace's cursor events
|
||||
rpc Attach (stream cursor.CursorEvent) returns (stream cursor.CursorEvent);
|
||||
}
|
|
@ -1,83 +1,56 @@
|
|||
syntax = "proto2";
|
||||
|
||||
package workspace;
|
||||
import "user.proto";
|
||||
import "files.proto";
|
||||
import "auth.proto";
|
||||
import "common.proto";
|
||||
|
||||
message Empty {}
|
||||
service Workspace {
|
||||
rpc CreateWorkspace (workspace.WorkspaceId) returns (common.Empty);
|
||||
|
||||
message TreeRequest {} // empty
|
||||
message UserRequest {}
|
||||
message CursorResponse {}
|
||||
message UserListRequest {}
|
||||
|
||||
message WorkspaceUserList {
|
||||
repeated user.UserIdentity user = 1;
|
||||
}
|
||||
|
||||
message WorkspaceMessage {
|
||||
required string id = 1; //unused???
|
||||
}
|
||||
|
||||
enum WorkspaceEventType {
|
||||
USER_JOIN = 0;
|
||||
USER_LEAVE = 1;
|
||||
FILE_CREATE = 2;
|
||||
FILE_DELETE = 3;
|
||||
FILE_RENAME = 4;
|
||||
rpc RequestAccess (workspace.BufferPath) returns (auth.Token);
|
||||
rpc LeaveWorkspace (workspace.WorkspaceId) returns (common.Empty);
|
||||
rpc CreateBuffer (workspace.BufferPath) returns (common.Empty);
|
||||
rpc ListBuffers (common.Empty) returns (files.BufferTree);
|
||||
rpc ListUsers (common.Empty) returns (common.UserList);
|
||||
rpc ListBufferUsers (workspace.BufferPath) returns (common.UserList); //TODO discuss
|
||||
rpc Attach (common.Empty) returns (stream workspace.WorkspaceEvent);
|
||||
rpc Delete (workspace.BufferPath) returns (common.Empty); //deletes buffer
|
||||
}
|
||||
|
||||
message WorkspaceEvent {
|
||||
required string id = 1; // the id of the user, or the path of the file
|
||||
required WorkspaceEventType event = 2;
|
||||
optional string extra = 3; // new name? extra info on user events etc...
|
||||
message UserJoin {
|
||||
required common.UserIdentity id = 1;
|
||||
}
|
||||
message UserLeave {
|
||||
required common.UserIdentity id = 1;
|
||||
}
|
||||
message FileCreate {
|
||||
required string path = 1;
|
||||
}
|
||||
message FileRename {
|
||||
required string before = 1;
|
||||
required string after = 2;
|
||||
}
|
||||
message FileDelete {
|
||||
required string path = 1;
|
||||
}
|
||||
|
||||
oneof event {
|
||||
UserJoin join = 1;
|
||||
UserLeave leave = 2;
|
||||
FileCreate create = 3;
|
||||
FileRename rename = 4;
|
||||
FileDelete delete = 5;
|
||||
}
|
||||
}
|
||||
|
||||
message JoinRequest {
|
||||
required string username = 1;
|
||||
required string password = 2;
|
||||
}
|
||||
|
||||
message AttachRequest {
|
||||
required string path = 1;
|
||||
}
|
||||
|
||||
message Token {
|
||||
required string token = 1;
|
||||
}
|
||||
|
||||
enum FileEventType {
|
||||
CREATE = 0;
|
||||
DELETE = 1;
|
||||
RENAME = 2;
|
||||
}
|
||||
|
||||
message FileEvent {
|
||||
required string bufferbuffertree = 1;
|
||||
required FileEventType type = 2;
|
||||
}
|
||||
|
||||
enum UserEventType {
|
||||
JOIN = 0;
|
||||
LEAVE = 1;
|
||||
}
|
||||
|
||||
message UserEvent {
|
||||
required user.UserIdentity user = 1;
|
||||
required UserEventType type = 2;
|
||||
}
|
||||
|
||||
message BufferPayload {
|
||||
message BufferPath {
|
||||
// buffer path to operate onto
|
||||
required string path = 1;
|
||||
}
|
||||
|
||||
message BufferListRequest {}
|
||||
|
||||
message UserList {
|
||||
repeated user.UserIdentity users = 1;
|
||||
}
|
||||
|
||||
message WorkspaceDetails {
|
||||
message WorkspaceId {
|
||||
required string id = 1;
|
||||
}
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
syntax = "proto2";
|
||||
|
||||
package workspace_service;
|
||||
import "user.proto";
|
||||
import "files.proto";
|
||||
import "workspace.proto";
|
||||
|
||||
service Workspace {
|
||||
rpc Attach (workspace.AttachRequest) returns (workspace.Token);
|
||||
rpc LeaveWorkspace (workspace.WorkspaceDetails) returns (workspace.Empty);
|
||||
rpc CreateWorkspace (workspace.WorkspaceDetails) returns (workspace.Empty);
|
||||
rpc CreateBuffer (workspace.BufferPayload) returns (workspace.Empty);
|
||||
rpc ListBuffers (workspace.BufferListRequest) returns (files.BufferTree);
|
||||
rpc ListUsers (workspace.UserListRequest) returns (workspace.UserList);
|
||||
rpc ListBufferUsers (workspace.BufferPayload) returns (workspace.UserList); //TODO discuss
|
||||
rpc Join (workspace.JoinRequest) returns (stream workspace.WorkspaceEvent);
|
||||
rpc Delete (workspace.BufferPayload) returns (workspace.Empty); //deletes buffer
|
||||
}
|
Loading…
Reference in a new issue