Skip to content

Commit 4df5e80

Browse files
ImeevMAlocker
authored andcommitted
proto: split proto-files
This patch splits the proto file into multiple specialized proto files. This patch also adds a warning that CRUD operations are experimental. Closes #2
1 parent dd778ec commit 4df5e80

8 files changed

+340
-268
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,15 @@
11
syntax = "proto3";
22

3-
package aeon_router;
3+
import "aeon_error.proto";
4+
import "aeon_value.proto";
5+
import "aeon_schema.proto";
46

5-
option go_package = "./pb";
7+
package aeon;
68

7-
// API to Aeon - a distributed database based on Tarantool.
8-
service AeonRouterService {
9-
//
10-
// Diagnostic requests.
11-
//
12-
13-
// Pings the router.
14-
rpc Ping(PingRequest) returns (PingResponse) {}
15-
16-
//
17-
// DDL requests.
18-
//
19-
20-
// Creates a space with the given definition.
21-
rpc CreateSpace(CreateSpaceRequest) returns (CreateSpaceResponse) {}
22-
23-
// Drops a space by name.
24-
rpc DropSpace(DropSpaceRequest) returns (DropSpaceResponse) {}
25-
26-
//
27-
// DML requests.
28-
//
9+
// ATTENTION: This module is EXPERIMENTAL and we do not recommend using it.
2910

11+
// CRUD API to Aeon - a distributed database based on Tarantool.
12+
service CRUDService {
3013
// Transactionally executes a set of read and write operations.
3114
rpc Execute(ExecuteRequest) returns (ExecuteResponse) {}
3215

@@ -47,222 +30,6 @@ service AeonRouterService {
4730

4831
// Non-transactionally select tuples from a space.
4932
rpc Select(SelectRequest) returns (stream SelectResponse) {}
50-
51-
//
52-
// SQL requests.
53-
//
54-
55-
// Execute a SQL query.
56-
rpc SQL(SQLRequest) returns (SQLResponse) {}
57-
58-
// Execute a SQL query and return the result using a stream.
59-
rpc SQLStream(SQLRequest) returns (stream SQLResponse) {}
60-
61-
// Check if an SQL is valid
62-
// We provide the method for database CLI.
63-
rpc SQLCheck(SQLRequest) returns (SQLCheckResponse) {}
64-
}
65-
66-
//
67-
// Common structures.
68-
//
69-
70-
// Special value denoting null.
71-
enum NullValue { NULL_VALUE = 0; }
72-
73-
// Array of arbitrary-typed values.
74-
message ArrayValue { repeated Value fields = 1; }
75-
76-
// Map with string keys and arbitrary-typed values..
77-
message MapValue { map<string, Value> fields = 1; }
78-
79-
// Date time value.
80-
message DateTimeValue {
81-
int64 seconds = 1;
82-
int64 nsec = 2;
83-
string location = 3;
84-
}
85-
86-
// Date time interval value.
87-
message IntervalValue {
88-
enum IntervalAdjust {
89-
INTERVAL_ADJUST_NONE = 0;
90-
INTERVAL_ADJUST_EXCESS = 1;
91-
INTERVAL_ADJUST_LAST = 2;
92-
}
93-
int64 year = 1;
94-
int64 month = 2;
95-
int64 week = 3;
96-
int64 day = 4;
97-
int64 hour = 5;
98-
int64 min = 6;
99-
int64 sec = 7;
100-
int64 nsec = 8;
101-
IntervalAdjust adjust = 9;
102-
}
103-
104-
// Arbitrary value that can be serialized to be sent over the network or
105-
// stored in the database.
106-
message Value {
107-
oneof kind {
108-
uint64 unsigned_value = 1;
109-
string string_value = 2;
110-
double number_value = 3;
111-
sint64 integer_value = 4;
112-
bool boolean_value = 5;
113-
bytes varbinary_value = 6;
114-
string decimal_value = 7;
115-
string uuid_value = 8;
116-
DateTimeValue datetime_value = 9;
117-
IntervalValue interval_value = 10;
118-
ArrayValue array_value = 11;
119-
MapValue map_value = 12;
120-
NullValue null_value = 13;
121-
}
122-
}
123-
124-
// Error information.
125-
message Error {
126-
// Error type.
127-
// * AeonError for core Aeon errors.
128-
// * AeonSQLError for issues with SQL parsing.
129-
// * AeonGRPCError for issues with gRPC encoding.
130-
string type = 1;
131-
// Error name.
132-
string name = 2;
133-
// Error location: file, line.
134-
string file = 3;
135-
uint64 line = 4;
136-
// Human-readable error description.
137-
string msg = 5;
138-
// System errno (usually not set).
139-
uint64 errno = 6;
140-
// Error code.
141-
uint64 code = 7;
142-
// Fields with extra information.
143-
MapValue fields = 8;
144-
// Previous error on the error stack (cause of this error).
145-
Error prev = 9;
146-
}
147-
148-
// Tuple: array of values.
149-
message Tuple { repeated Value fields = 1; }
150-
151-
// Tuple format: array of field names.
152-
message TupleFormat { repeated string names = 1; }
153-
154-
// Read or write operation executed in a transaction.
155-
message Operation {
156-
// Target space name.
157-
string space = 1;
158-
// Target key in the space. Must be full (have all defined key parts).
159-
Tuple key = 2;
160-
// In a request:
161-
// * Ignored for read operations.
162-
// * Specifies the tuple to write in a write operation.
163-
// In a response:
164-
// * Tuple read from or written to the target space.
165-
// The write operation type depends on the tuple value:
166-
// * NOP if the tuple is not set.
167-
// * DELETE if the tuple is set but has no fields.
168-
// * REPLACE otherwise. The tuple must match the target key.
169-
// The tuple may be overwritten by the user-defined function specified in
170-
// a request to change the written value or even operation type depending on
171-
// read values.
172-
Tuple tuple = 3;
173-
}
174-
175-
// Type a space field can have.
176-
enum FieldType {
177-
FIELD_TYPE_UNSPECIFIED = 0;
178-
FIELD_TYPE_ANY = 1;
179-
FIELD_TYPE_UNSIGNED = 2;
180-
FIELD_TYPE_STRING = 3;
181-
FIELD_TYPE_NUMBER = 4;
182-
FIELD_TYPE_DOUBLE = 5;
183-
FIELD_TYPE_INTEGER = 6;
184-
FIELD_TYPE_BOOLEAN = 7;
185-
FIELD_TYPE_VARBINARY = 8;
186-
FIELD_TYPE_SCALAR = 9;
187-
FIELD_TYPE_DECIMAL = 10;
188-
FIELD_TYPE_UUID = 11;
189-
FIELD_TYPE_DATETIME = 12;
190-
FIELD_TYPE_INTERVAL = 13;
191-
FIELD_TYPE_ARRAY = 14;
192-
FIELD_TYPE_MAP = 15;
193-
}
194-
195-
// Space field definition.
196-
message FieldDef {
197-
// Field name.
198-
string name = 1;
199-
// Field type.
200-
FieldType type = 2;
201-
// If set to true, the field may store null values. Optional.
202-
bool is_nullable = 3;
203-
}
204-
205-
// Key part definition.
206-
message KeyPartDef {
207-
enum KeyPartSortOrder {
208-
KEY_PART_SORT_ORDER_ASC = 0;
209-
KEY_PART_SORT_ORDER_DESC = 1;
210-
}
211-
// Indexed field ordinal number (1-based) or name.
212-
oneof field {
213-
uint64 id = 1;
214-
string name = 2;
215-
}
216-
// Key part type. Optional: if omitted, it will be deduced from
217-
// the corresponding space field type.
218-
FieldType type = 3;
219-
// Sorting order: ascending (default) or descending.
220-
KeyPartSortOrder sort_order = 4;
221-
}
222-
223-
//
224-
// Diagnostic requests.
225-
//
226-
227-
// Pings the router.
228-
229-
message PingRequest {}
230-
231-
message PingResponse {
232-
// Error information. Set only on failure.
233-
Error error = 1;
234-
}
235-
236-
//
237-
// DDL requests.
238-
//
239-
240-
// Creates a space with the given definition.
241-
242-
message CreateSpaceRequest {
243-
// Name of the new space.
244-
string name = 1;
245-
// Format of the new space.
246-
repeated FieldDef format = 2;
247-
// Sorting key definition (indexed fields).
248-
repeated KeyPartDef key_def = 3;
249-
}
250-
251-
message CreateSpaceResponse {
252-
// Error information. Set only on failure.
253-
Error error = 1;
254-
}
255-
256-
// Drops a space by name.
257-
258-
message DropSpaceRequest {
259-
// Name of the space to drop.
260-
string name = 1;
261-
}
262-
263-
message DropSpaceResponse {
264-
// Error information. Set only on failure.
265-
Error error = 1;
26633
}
26734

26835
//
@@ -496,31 +263,3 @@ message SelectResponse {
496263
// Format of the returned tuples.
497264
TupleFormat tuple_format = 8;
498265
}
499-
500-
//
501-
// SQL requests.
502-
//
503-
504-
message SQLRequest {
505-
// SQL query.
506-
string query = 1;
507-
// Bind variables.
508-
map<string, Value> vars = 2;
509-
}
510-
511-
message SQLResponse {
512-
// Error information. Set only on failure.
513-
Error error = 1;
514-
// Retrieved tuples.
515-
repeated Tuple tuples = 2;
516-
// Format of the returned tuples.
517-
TupleFormat tuple_format = 3;
518-
}
519-
520-
enum SQLCheckStatus {
521-
SQL_QUERY_VALID = 0;
522-
SQL_QUERY_INCOMPLETE = 1;
523-
SQL_QUERY_INVALID = 2;
524-
}
525-
526-
message SQLCheckResponse { SQLCheckStatus status = 1; }

aeon_ddl.proto

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
syntax = "proto3";
2+
3+
import "aeon_error.proto";
4+
import "aeon_schema.proto";
5+
6+
package aeon;
7+
8+
// DDL API to Aeon - a distributed database based on Tarantool.
9+
service DDLService {
10+
// Creates a space with the given definition.
11+
rpc CreateSpace(CreateSpaceRequest) returns (CreateSpaceResponse) {}
12+
13+
// Drops a space by name.
14+
rpc DropSpace(DropSpaceRequest) returns (DropSpaceResponse) {}
15+
}
16+
17+
// Creates a space with the given definition.
18+
19+
message CreateSpaceRequest {
20+
// Name of the new space.
21+
string name = 1;
22+
// Format of the new space.
23+
repeated FieldDef format = 2;
24+
// Sorting key definition (indexed fields).
25+
repeated KeyPartDef key_def = 3;
26+
}
27+
28+
message CreateSpaceResponse {
29+
// Error information. Set only on failure.
30+
Error error = 1;
31+
}
32+
33+
// Drops a space by name.
34+
35+
message DropSpaceRequest {
36+
// Name of the space to drop.
37+
string name = 1;
38+
}
39+
40+
message DropSpaceResponse {
41+
// Error information. Set only on failure.
42+
Error error = 1;
43+
}

aeon_diag.proto

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
syntax = "proto3";
2+
3+
import "aeon_error.proto";
4+
5+
package aeon;
6+
7+
// Diagnostic API to Aeon - a distributed database based on Tarantool.
8+
service DiagService {
9+
// Pings the router.
10+
rpc Ping(PingRequest) returns (PingResponse) {}
11+
}
12+
13+
// Pings the router.
14+
15+
message PingRequest {}
16+
17+
message PingResponse {
18+
// Error information. Set only on failure.
19+
Error error = 1;
20+
}

aeon_error.proto

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
syntax = "proto3";
2+
3+
import "aeon_value.proto";
4+
5+
package aeon;
6+
7+
// Error information.
8+
message Error {
9+
// Error type.
10+
// * AeonError for core Aeon errors.
11+
// * AeonSQLError for issues with SQL parsing.
12+
// * AeonGRPCError for issues with gRPC encoding.
13+
string type = 1;
14+
// Error name.
15+
string name = 2;
16+
// Error location: file, line.
17+
string file = 3;
18+
uint64 line = 4;
19+
// Human-readable error description.
20+
string msg = 5;
21+
// System errno (usually not set).
22+
uint64 errno = 6;
23+
// Error code.
24+
uint64 code = 7;
25+
// Fields with extra information.
26+
MapValue fields = 8;
27+
// Previous error on the error stack (cause of this error).
28+
Error prev = 9;
29+
}

0 commit comments

Comments
 (0)