1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 05:57:03 +09:00
any-sync/common/commonspace/spacesyncproto/protos/spacesync.proto
Sergey Cherepanov 2c3ebf9ce1
go workspaces
2022-10-17 15:31:09 +03:00

129 lines
3.4 KiB
Protocol Buffer

syntax = "proto3";
package anySpace;
option go_package = "commonspace/spacesyncproto";
import "pkg/acl/treechangeproto/protos/treechange.proto";
import "pkg/acl/aclrecordproto/protos/aclrecord.proto";
enum ErrCodes {
Unexpected = 0;
SpaceMissing = 1;
SpaceExists = 2;
ErrorOffset = 100;
}
service Space {
// HeadSync compares all objects and their hashes in a space
rpc HeadSync(HeadSyncRequest) returns (HeadSyncResponse);
// PushSpace sends new space to the node
rpc PushSpace(PushSpaceRequest) returns (PushSpaceResponse);
// Stream opens object sync stream with node or client
rpc Stream(stream ObjectSyncMessage) returns (stream ObjectSyncMessage);
}
// HeadSyncRange presenting a request for one range
message HeadSyncRange {
uint64 from = 1;
uint64 to = 2;
uint32 limit = 3;
}
// HeadSyncResult presenting a response for one range
message HeadSyncResult {
bytes hash = 1;
repeated HeadSyncResultElement elements = 2;
uint32 count = 3;
}
// HeadSyncResultElement presenting state of one object
message HeadSyncResultElement {
string id = 1;
string head = 2;
}
// HeadSyncRequest is a request for HeadSync
message HeadSyncRequest {
string spaceId = 1;
repeated HeadSyncRange ranges = 2;
}
// HeadSyncResponse is a response for HeadSync
message HeadSyncResponse {
repeated HeadSyncResult results = 1;
}
// ObjectSyncMessage is a message sent on object sync
message ObjectSyncMessage {
string spaceId = 1;
ObjectSyncContentValue content = 2;
treechange.RawTreeChangeWithId rootChange = 3;
string treeId = 4;
string trackingId = 5;
// string identity = 5;
// string peerSignature = 6;
}
// ObjectSyncContentValue provides different types for object sync
message ObjectSyncContentValue {
oneof value {
ObjectHeadUpdate headUpdate = 1;
ObjectFullSyncRequest fullSyncRequest = 2;
ObjectFullSyncResponse fullSyncResponse = 3;
ObjectErrorResponse errorResponse = 4;
}
}
// ObjectHeadUpdate is a message sent on document head update
message ObjectHeadUpdate {
repeated string heads = 1;
repeated treechange.RawTreeChangeWithId changes = 2;
repeated string snapshotPath = 3;
}
// ObjectHeadUpdate is a message sent when document needs full sync
message ObjectFullSyncRequest {
repeated string heads = 1;
repeated treechange.RawTreeChangeWithId changes = 2;
repeated string snapshotPath = 3;
}
// ObjectFullSyncResponse is a message sent as a response for a specific full sync
message ObjectFullSyncResponse {
repeated string heads = 1;
repeated treechange.RawTreeChangeWithId changes = 2;
repeated string snapshotPath = 3;
}
// ObjectErrorResponse is an error sent as a response for a full sync request
message ObjectErrorResponse {
string error = 1;
}
// PushSpaceRequest is a request to add space on a node containing only one acl record
message PushSpaceRequest {
RawSpaceHeaderWithId spaceHeader = 2;
aclrecord.RawACLRecordWithId aclRoot = 3;
}
// PushSpaceResponse is an empty response
message PushSpaceResponse {}
// SpaceHeader is a header for a space
message SpaceHeader {
bytes identity = 1;
int64 timestamp = 2;
string spaceType = 3;
uint64 replicationKey = 4;
bytes seed = 5;
}
message RawSpaceHeader {
bytes spaceHeader = 1;
bytes signature = 2;
}
message RawSpaceHeaderWithId {
bytes rawHeader = 1;
string id = 2;
}