mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
153 lines
3.9 KiB
Protocol Buffer
153 lines
3.9 KiB
Protocol Buffer
syntax = "proto3";
|
|
package spacesync;
|
|
|
|
option go_package = "commonspace/spacesyncproto";
|
|
|
|
enum ErrCodes {
|
|
Unexpected = 0;
|
|
SpaceMissing = 1;
|
|
SpaceExists = 2;
|
|
SpaceNotInCache = 3;
|
|
SpaceIsDeleted = 4;
|
|
ErrorOffset = 100;
|
|
}
|
|
|
|
service SpaceSync {
|
|
// HeadSync compares all objects and their hashes in a space
|
|
rpc HeadSync(HeadSyncRequest) returns (HeadSyncResponse);
|
|
// SpacePush sends new space to the node
|
|
rpc SpacePush(SpacePushRequest) returns (SpacePushResponse);
|
|
// SpacePull gets space from the remote peer
|
|
rpc SpacePull(SpacePullRequest) returns (SpacePullResponse);
|
|
// ObjectSyncStream opens object sync stream with node or client
|
|
rpc ObjectSyncStream(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;
|
|
string requestId = 2;
|
|
string replyId = 3;
|
|
bytes payload = 4;
|
|
string objectId = 5;
|
|
}
|
|
|
|
// SpacePushRequest is a request to add space on a node containing only one acl record
|
|
message SpacePushRequest {
|
|
SpacePayload payload = 1;
|
|
}
|
|
|
|
// SpacePushResponse is an empty response
|
|
message SpacePushResponse {}
|
|
|
|
// SpacePullRequest is a request to request a space on a node that doesn't have it
|
|
message SpacePullRequest {
|
|
string id = 1;
|
|
}
|
|
|
|
// SpacePullResponse is a response with header and acl root
|
|
message SpacePullResponse {
|
|
SpacePayload payload = 1;
|
|
}
|
|
|
|
// SpacePayload is a payload for pushing a space
|
|
message SpacePayload {
|
|
RawSpaceHeaderWithId spaceHeader = 1;
|
|
bytes aclPayload = 2;
|
|
string aclPayloadId = 3;
|
|
bytes spaceSettingsPayload = 4;
|
|
string spaceSettingsPayloadId = 5;
|
|
}
|
|
|
|
// SpaceHeader is a header for a space
|
|
message SpaceHeader {
|
|
bytes identity = 1;
|
|
int64 timestamp = 2;
|
|
string spaceType = 3;
|
|
uint64 replicationKey = 4;
|
|
bytes seed = 5;
|
|
}
|
|
|
|
// RawSpaceHeader is raw header for SpaceHeader
|
|
message RawSpaceHeader {
|
|
bytes spaceHeader = 1;
|
|
bytes signature = 2;
|
|
}
|
|
|
|
// RawSpaceHeaderWithId is a marshalled RawSpaceHeader with its content id
|
|
message RawSpaceHeaderWithId {
|
|
bytes rawHeader = 1;
|
|
string id = 2;
|
|
}
|
|
|
|
// SpaceSettingsContent is a payload for a space settings object
|
|
message SpaceSettingsContent {
|
|
oneof value {
|
|
ObjectDelete objectDelete = 1;
|
|
SpaceDelete spaceDelete = 2;
|
|
}
|
|
}
|
|
|
|
// ObjectDelete is a message containing an object id which should be deleted
|
|
message ObjectDelete {
|
|
string id = 1;
|
|
}
|
|
|
|
// SpaceDelete is a message containing timestamp when space was deleted
|
|
message SpaceDelete {
|
|
int64 timestamp = 1;
|
|
}
|
|
|
|
// SpaceSettingsSnapshot contains all the deleted ids in a snapshot
|
|
message SpaceSettingsSnapshot {
|
|
repeated string deletedIds = 1;
|
|
int64 spaceDeletionTimestamp = 2;
|
|
}
|
|
|
|
// SettingsData contains ObjectTree change payload
|
|
message SettingsData {
|
|
repeated SpaceSettingsContent content = 1;
|
|
SpaceSettingsSnapshot snapshot = 2;
|
|
}
|
|
|
|
// SpaceSubscription contains in ObjectSyncMessage.Payload and indicates that we need to subscribe or unsubscribe the current stream to this space
|
|
enum SpaceSubscriptionAction {
|
|
Subscribe = 0;
|
|
Unsubscribe = 1;
|
|
}
|
|
|
|
message SpaceSubscription {
|
|
repeated string spaceIds = 1;
|
|
SpaceSubscriptionAction action = 2;
|
|
}
|