new changes to proto

This commit is contained in:
frelodev 2023-12-18 23:36:15 +01:00
parent 18290d768c
commit 2f1bfab130
10 changed files with 198 additions and 280 deletions

View file

@ -1,75 +0,0 @@
syntax = "proto3";
package buffer;
import "proto/user.proto";
// handle buffer changes, keep in sync users
service Buffer {
// attach to a buffer and receive operations
rpc Attach (BufferPayload) returns (stream RawOp);
// send an operation for a specific buffer
rpc Edit (OperationRequest) returns (BufferEditResponse);
// create a new buffer
rpc Create (BufferPayload) returns (BufferCreateResponse);
// get contents of buffer
rpc Sync (BufferPayload) returns (BufferResponse);
}
message BufferView {
int32 id = 1;
BufferMetadata metadata = 2;
}
message BufferMetadata {
string name = 2;
string path = 3;
uint64 created = 4; // unix timestamp
repeated user.UserIdentity attached_users = 5;
}
// empty request
message BufferCreateResponse {}
// empty request
message BufferEditResponse {}
// raw wire operation sequence event
message RawOp {
// operation seq serialized to json
string opseq = 1;
// user id that has executed the operation
string user = 2;
}
// client buffer operation request
message OperationRequest {
// buffer path to operate onto
string path = 1;
// buffer hash of source state
string hash = 2;
// raw operation sequence
RawOp op = 3;
}
// generic buffer operation request
message BufferPayload {
// buffer path to operate onto
string path = 1;
// user id that is requesting the operation
string user = 2;
// optional buffer full content for replacing
optional string content = 3;
}
// response from server with buffer content
message BufferResponse {
// current buffer content
string content = 1;
}

View file

@ -0,0 +1,15 @@
syntax = "proto2";
package codemp.buffer_service;
// handle buffer changes, keep in sync users
service Buffer {
// attach to a buffer and receive operations
rpc Attach (stream Operation) returns (stream Operation);
}
message Operation {
required bytes data = 1;
optional string user = 2;
optional string path = 3;
}

View file

@ -1,44 +0,0 @@
syntax = "proto3";
package cursor;
// handle cursor events and broadcast to all users
service Cursor {
// send cursor movement to server
rpc Moved (CursorEvent) returns (MovedResponse);
// attach to a workspace and receive cursor events
rpc Listen (UserIdentity) returns (stream CursorEvent);
}
// empty request
message MovedResponse {}
// a tuple indicating row and column
message RowCol {
int32 row = 1;
int32 col = 2;
}
// cursor position object
message CursorPosition {
// path of current buffer this cursor is into
string buffer = 1;
// cursor start position
RowCol start = 2;
// cursor end position
RowCol end = 3;
}
// cursor event, with user id and cursor position
message CursorEvent {
// user moving the cursor
string user = 1;
// new cursor position
CursorPosition position = 2;
}
// payload identifying user for cursor attaching
message UserIdentity {
// user identifier
string id = 1;
}

View file

@ -0,0 +1,13 @@
syntax = "proto2";
package codemp.cursor;
import "proto/model/cursor.proto";
import "proto/model/user.proto";
// handle cursor events and broadcast to all users
service Cursor {
// send cursor movement to server
rpc Moved (cursor.CursorEvent) returns (cursor.MovedResponse);
// attach to a workspace and receive cursor events
rpc Listen (codemp.model.user.UserIdentity) returns (stream cursor.CursorEvent);
}

32
proto/model/cursor.proto Normal file
View file

@ -0,0 +1,32 @@
syntax = "proto2";
package codemp.model.cursor;
import "proto/model/user.proto";
// empty request
message MovedResponse {}
// a tuple indicating row and column
message RowCol {
required int32 row = 1;
required int32 col = 2;
}
// cursor position object
message CursorPosition {
// path of current buffer this cursor is into
required string buffer = 1;
// cursor start position
required RowCol start = 2;
// cursor end position
required RowCol end = 3;
}
// cursor event, with user id and cursor position
message CursorEvent {
// user moving the cursor
required codemp.model.user.UserIdentity user = 1;
// new cursor position
required CursorPosition position = 2;
}

0
proto/model/files.proto Normal file
View file

View file

@ -1,12 +1,12 @@
syntax = "proto3";
syntax = "proto2";
package user;
package codemp.model.user;
// payload identifying user
message UserIdentity {
// user identifier
string id = 1;
required string id = 1;
}
service User{

View file

View file

@ -1,158 +0,0 @@
// Workspace effimero: sta in /tmp o proprio in memoria
// Workspace e` autenticato: come si decide mentre si rifa il server
// Workspace ha id univoco (stringa), usato per connettercisi
// Workspace implementera` access control:
// * accedere al workspace
// * i singoli buffer
// - i metadati maybe????
// Workspace offre le seguenti features:
// * listare i buffer DONE
// * listare gli user connessi DONE
// * creare buffers DONE REPLACE THE ONE ON buffer.proto
// * NO ATTACH: responsabilita` del buffer service
// * contiene metadata dei buffers:
// * path
// * data creazione
// Buffer id NON E` il path DONE
// BufferService NON ha metadata:
// Workspace tiene traccia di utenti attached (nel futuro) DONE
syntax = "proto3";
package workspace;
import "proto/user.proto";
import "proto/buffer.proto";
message Empty {}
message WorkspaceEvent {
oneof event {
CursorEvent cursor = 1;
FileEvent file = 2;
UserEvent user = 3;
}
}
message WorkspaceFileTree {
// list of strings may be more efficient but it's a lot more hassle
string payload = 1; // spappolata di json
}
message WorkspaceUserList {
repeated user.UserIdentity user = 1;
}
message WorkspaceMessage {
int32 id = 1;
}
message TreeRequest {} // empty
message UserRequest {}
message CursorResponse{}
message UserListRequest{}
service Workspace {
//
rpc Create (BufferPayload) returns (BufferCreateResponse);
rpc ListBuffers (BufferListRequest) returns (BufferList);
rpc ListUsers (UserListRequest) returns (UserList);
//
rpc Join (user.UserIdentity) returns (stream WorkspaceEvent);
//
rpc Tree (TreeRequest) returns (WorkspaceFileTree);
//
rpc Users (UserRequest) returns (WorkspaceUserList); // TODO could be handled by cursor service
// send cursor movement to server
rpc Cursor (CursorEvent) returns (CursorResponse);
}
// a tuple indicating row and column
message RowCol {
int32 row = 1;
int32 col = 2;
}
// cursor position object
message CursorPosition {
// cursor start position
RowCol start = 1;
// cursor end position
RowCol end = 2;
}
// cursor event, with user id and cursor position
message CursorEvent {
// user moving the cursor
string user = 1;
// path of current buffer this cursor is into
string buffer = 2;
// new cursor position
repeated CursorPosition position = 3;
}
enum FileEventType {
CREATE = 0;
DELETE = 1;
RENAME = 2;
}
message FileEvent {
string buffer = 1;
FileEventType type = 2;
}
enum UserEventType {
JOIN = 0;
LEAVE = 1;
}
message UserEvent {
user.UserIdentity user = 1;
UserEventType type = 2;
}
message BufferPayload {
// buffer path to operate onto
string path = 1;
// user id that is requesting the operation
user.UserIdentity user = 2;
// optional buffer full content for replacing
optional string content = 3;
}
message BufferCreateResponse {
string status = 1;
}
message BufferListRequest{
}
message BufferList{
repeated buffer.BufferView buffers = 1;
}
message UserList{
repeated user.UserIdentity users = 1;
}

View file

@ -0,0 +1,135 @@
// Workspace effimero: sta in /tmp o proprio in memoria
// Workspace e` autenticato: come si decide mentre si rifa il server
// Workspace ha id univoco (stringa), usato per connettercisi
// Workspace implementera` access control:
// * accedere al workspace
// * i singoli buffer
// - i metadati maybe????
// Workspace offre le seguenti features:
// * listare i buffer DONE
// * listare gli user connessi DONE
// * creare buffers DONE REPLACE THE ONE ON buffer.proto
// * NO ATTACH: responsabilita` del buffer service
// * contiene metadata dei buffers:
// * path
// * data creazione
// Buffer id NON E` il path DONE
// BufferService NON ha metadata:
// Workspace tiene traccia di utenti attached (nel futuro) DONE
syntax = "proto2";
package codemp.workspace_service;
import "proto/model/cursor.proto";
import "proto/model/user.proto";
message Empty {}
message WorkspaceFileTree {
// list of strings may be more efficient but it's a lot more hassle
required string payload = 1; // spappolata di json
}
message WorkspaceUserList {
repeated codemp.model.user.UserIdentity user = 1;
}
message WorkspaceMessage {
required int32 id = 1;
}
message TreeRequest {} // empty
message UserRequest {}
message CursorResponse{}
message UserListRequest{}
service Workspace {
//
rpc Create (BufferPayload) returns (Empty);
rpc Attach (AttachRequest) returns (Token);
rpc ListBuffers (BufferListRequest) returns (Empty);
rpc ListUsers (UserListRequest) returns (UserList);
rpc Join (JoinRequest) returns (Token);
}
message JoinRequest{
required string username=1;
required string password=2;
}
message AttachRequest{
required string bufferAttach = 1;
}
message Token{
required string token = 1;
}
enum FileEventType {
CREATE = 0;
DELETE = 1;
RENAME = 2;
}
message FileEvent {
required string buffer = 1;
required FileEventType type = 2;
}
enum UserEventType {
JOIN = 0;
LEAVE = 1;
}
message UserEvent {
required codemp.model.user.UserIdentity user = 1;
required UserEventType type = 2;
}
message BufferPayload {
// buffer path to operate onto
required string path = 1;
// user id that is requesting the operation
required codemp.model.user.UserIdentity user = 2;
}
message BufferListRequest{
}
message BufferNode{
required string path = 1;
}
message BufferTree{
repeated BufferNode buffers = 1;
}
message UserList{
repeated codemp.model.user.UserIdentity users = 1;
}