[#1334] services/tree: Document *.proto files

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-05-19 14:53:16 +03:00
parent c8fce0d3e4
commit 2c8a87a469
2 changed files with 96 additions and 1 deletions

View file

@ -1,3 +1,6 @@
/**
* Service for working with CRDT tree.
*/
syntax = "proto3"; syntax = "proto3";
package tree; package tree;
@ -6,7 +9,6 @@ import "pkg/services/tree/types.proto";
option go_package = "github.com/nspcc-dev/neofs-node/pkg/services/tree"; option go_package = "github.com/nspcc-dev/neofs-node/pkg/services/tree";
// `TreeService` provides an interface for working with distributed tree.
service TreeService { service TreeService {
/* Client API */ /* Client API */
@ -28,66 +30,95 @@ service TreeService {
// Apply pushes log operation from another node to the current. // Apply pushes log operation from another node to the current.
// The request must be signed by a container node. // The request must be signed by a container node.
rpc Apply (ApplyRequest) returns (ApplyResponse); rpc Apply (ApplyRequest) returns (ApplyResponse);
// GetOpLog returns a stream of logged operations starting from some height.
rpc GetOpLog(GetOpLogRequest) returns (stream GetOpLogResponse); rpc GetOpLog(GetOpLogRequest) returns (stream GetOpLogResponse);
} }
message AddRequest { message AddRequest {
message Body { message Body {
// Container ID in V2 format.
bytes container_id = 1; bytes container_id = 1;
// The name of the tree.
string tree_id = 2; string tree_id = 2;
// ID of the parent to attach node to.
uint64 parent_id = 3; uint64 parent_id = 3;
// Key-Value pairs with meta information.
repeated KeyValue meta = 4; repeated KeyValue meta = 4;
// Bearer token in V2 format.
bytes bearer_token = 5; bytes bearer_token = 5;
} }
// Request body.
Body body = 1; Body body = 1;
// Request signature.
Signature signature = 2; Signature signature = 2;
} }
message AddResponse { message AddResponse {
message Body { message Body {
// ID of the created node.
uint64 node_id = 1; uint64 node_id = 1;
} }
// Response body.
Body body = 1; Body body = 1;
// Response signature.
Signature signature = 2; Signature signature = 2;
}; };
message AddByPathRequest { message AddByPathRequest {
message Body { message Body {
// Container ID in V2 format.
bytes container_id = 1; bytes container_id = 1;
// The name of the tree.
string tree_id = 2; string tree_id = 2;
// Attribute to build path with. Default: "FileName".
string path_attribute = 3; string path_attribute = 3;
// List of path components.
repeated string path = 4; repeated string path = 4;
// Node meta-information.
repeated KeyValue meta = 5; repeated KeyValue meta = 5;
// Bearer token in V2 format.
bytes bearer_token = 6; bytes bearer_token = 6;
} }
// Request body.
Body body = 1; Body body = 1;
// Request signature.
Signature signature = 2; Signature signature = 2;
} }
message AddByPathResponse { message AddByPathResponse {
message Body { message Body {
// List of all created nodes. The first one is the leaf.
repeated uint64 nodes = 1; repeated uint64 nodes = 1;
// ID of the parent node where new nodes were attached.
uint64 parent_id = 2; uint64 parent_id = 2;
} }
// Response body.
Body body = 1; Body body = 1;
// Response signature.
Signature signature = 2; Signature signature = 2;
}; };
message RemoveRequest { message RemoveRequest {
message Body { message Body {
// Container ID in V2 format.
bytes container_id = 1; bytes container_id = 1;
// The name of the tree.
string tree_id = 2; string tree_id = 2;
// ID of the node to remove.
uint64 node_id = 3; uint64 node_id = 3;
// Bearer token in V2 format.
bytes bearer_token = 4; bytes bearer_token = 4;
} }
// Request body.
Body body = 1; Body body = 1;
// Request signature.
Signature signature = 2; Signature signature = 2;
} }
@ -95,7 +126,9 @@ message RemoveResponse {
message Body { message Body {
} }
// Response body.
Body body = 1; Body body = 1;
// Response signature.
Signature signature = 2; Signature signature = 2;
}; };
@ -103,15 +136,23 @@ message RemoveResponse {
message MoveRequest { message MoveRequest {
message Body { message Body {
// TODO import neo.fs.v2.refs.ContainerID directly. // TODO import neo.fs.v2.refs.ContainerID directly.
// Container ID in V2 format.
bytes container_id = 1; bytes container_id = 1;
// The name of the tree.
string tree_id = 2; string tree_id = 2;
// ID of the new parent.
uint64 parent_id = 3; uint64 parent_id = 3;
// ID of the node to move.
uint64 node_id = 4; uint64 node_id = 4;
// Node meta-information.
repeated KeyValue meta = 5; repeated KeyValue meta = 5;
// Bearer token in V2 format.
bytes bearer_token = 6; bytes bearer_token = 6;
} }
// Request body.
Body body = 1; Body body = 1;
// Request signature.
Signature signature = 2; Signature signature = 2;
} }
@ -119,78 +160,114 @@ message MoveResponse {
message Body { message Body {
} }
// Response body.
Body body = 1; Body body = 1;
// Response signature.
Signature signature = 2; Signature signature = 2;
}; };
message GetNodeByPathRequest { message GetNodeByPathRequest {
message Body { message Body {
// Container ID in V2 format.
bytes container_id = 1; bytes container_id = 1;
// The name of the tree.
string tree_id = 2; string tree_id = 2;
// Attribute to build path with. Default: "FileName".
string path_attribute = 3; string path_attribute = 3;
// List of path components.
repeated string path = 4; repeated string path = 4;
// List of attributes to include in response.
repeated string attributes = 5; repeated string attributes = 5;
// Flag to return only the latest version of node.
bool latest_only = 6; bool latest_only = 6;
// Flag to return all stored attributes.
bool all_attributes = 7; bool all_attributes = 7;
// Bearer token in V2 format.
bytes bearer_token = 8; bytes bearer_token = 8;
} }
// Request body.
Body body = 1; Body body = 1;
// Request signature.
Signature signature = 2; Signature signature = 2;
} }
message GetNodeByPathResponse { message GetNodeByPathResponse {
// Information about a single tree node.
message Info { message Info {
// Node ID.
uint64 node_id = 1; uint64 node_id = 1;
// Timestamp of the last operation with the node.
uint64 timestamp = 2; uint64 timestamp = 2;
// Node meta-information.
repeated KeyValue meta = 3; repeated KeyValue meta = 3;
} }
message Body { message Body {
// List of nodes stored by path.
repeated Info nodes = 1; repeated Info nodes = 1;
} }
// Response body.
Body body = 1; Body body = 1;
// Response signature.
Signature signature = 2; Signature signature = 2;
}; };
message GetSubTreeRequest { message GetSubTreeRequest {
message Body { message Body {
// Container ID in V2 format.
bytes container_id = 1; bytes container_id = 1;
// The name of the tree.
string tree_id = 2; string tree_id = 2;
// ID of the root node of a subtree.
uint64 root_id = 3; uint64 root_id = 3;
// Optional depth of the traversal. Zero means return only root. // Optional depth of the traversal. Zero means return only root.
// Maximum depth is 10. // Maximum depth is 10.
uint32 depth = 4; uint32 depth = 4;
// Bearer token in V2 format.
bytes bearer_token = 5; bytes bearer_token = 5;
} }
// Request body.
Body body = 1; Body body = 1;
// Request signature.
Signature signature = 2; Signature signature = 2;
} }
message GetSubTreeResponse { message GetSubTreeResponse {
message Body { message Body {
// ID of the node.
uint64 node_id = 1; uint64 node_id = 1;
// ID of the parent.
uint64 parent_id = 2; uint64 parent_id = 2;
// Time node was first added to a tree.
uint64 timestamp = 3; uint64 timestamp = 3;
// Node meta-information.
repeated KeyValue meta = 4; repeated KeyValue meta = 4;
} }
// Response body.
Body body = 1; Body body = 1;
// Response signature.
Signature signature = 2; Signature signature = 2;
}; };
message ApplyRequest { message ApplyRequest {
message Body { message Body {
// Container ID in V2 format.
bytes container_id = 1; bytes container_id = 1;
// The name of the tree.
string tree_id = 2; string tree_id = 2;
// Operation to be applied.
LogMove operation = 3; LogMove operation = 3;
} }
// Request body.
Body body = 1; Body body = 1;
// Request signature.
Signature signature = 2; Signature signature = 2;
} }
@ -198,28 +275,39 @@ message ApplyResponse {
message Body { message Body {
} }
// Response body.
Body body = 1; Body body = 1;
// Response signature.
Signature signature = 2; Signature signature = 2;
}; };
message GetOpLogRequest { message GetOpLogRequest {
message Body { message Body {
// Container ID in V2 format.
bytes container_id = 1; bytes container_id = 1;
// The name of the tree.
string tree_id = 2; string tree_id = 2;
// Starting height to return logs from.
uint64 height = 3; uint64 height = 3;
// Amount of operations to return.
uint64 count = 4; uint64 count = 4;
} }
// Request body.
Body body = 1; Body body = 1;
// Request signature.
Signature signature = 2; Signature signature = 2;
} }
message GetOpLogResponse { message GetOpLogResponse {
message Body { message Body {
// Operation on a tree.
LogMove operation = 1; LogMove operation = 1;
} }
// Response body.
Body body = 1; Body body = 1;
// Response signature.
Signature signature = 2; Signature signature = 2;
}; };

View file

@ -1,3 +1,6 @@
/**
* Auxiliary structures to use with tree service.
*/
syntax = "proto3"; syntax = "proto3";
package tree; package tree;
@ -6,7 +9,9 @@ option go_package = "github.com/nspcc-dev/neofs-node/pkg/services/tree";
// KeyValue represents key-value pair attached to an object. // KeyValue represents key-value pair attached to an object.
message KeyValue { message KeyValue {
// Attribute name.
string key = 1 [json_name = "key"]; string key = 1 [json_name = "key"];
// Attribute value.
bytes value = 2 [json_name = "value"]; bytes value = 2 [json_name = "value"];
} }
@ -22,6 +27,8 @@ message LogMove {
// Signature of a message. // Signature of a message.
message Signature { message Signature {
// Serialized public key as defined in NeoFS API.
bytes key = 1 [json_name = "key"]; bytes key = 1 [json_name = "key"];
// Signature of a message body.
bytes sign = 2 [json_name = "signature"]; bytes sign = 2 [json_name = "signature"];
} }