Skip to content

Commit 3c844de

Browse files
Add protocol versioning transmitted during connection open (#185)
## What is the goal of this PR? We add a new connection opening request, which allows transmitting the protocol version for the server to verify. ## What are the changes implemented in this PR? * Add new service: `connection`, which takes `Connection.Req` and returns `Connection.Res` * Add new protocol message: `connection.proto`, which contains `Open.Req|Res` * Add new protocol message: `version.proto`, which holds an Enum encoding the protocol version number
1 parent 5c073e6 commit 3c844de

File tree

10 files changed

+95
-1
lines changed

10 files changed

+95
-1
lines changed

cluster/cluster_service.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ option java_package = "com.vaticle.typedb.protocol";
2121
option java_outer_classname = "ClusterServiceProto";
2222
option java_generic_services = true;
2323

24-
2524
import "cluster/cluster_server.proto";
2625
import "cluster/cluster_user.proto";
2726
import "cluster/cluster_database.proto";

common/BUILD

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ proto_library(
3030
srcs = ["concept.proto"],
3131
)
3232

33+
proto_library(
34+
name = "connection-proto",
35+
srcs = ["connection.proto"],
36+
deps = [
37+
":version-proto",
38+
],
39+
)
40+
3341
proto_library(
3442
name = "logic-proto",
3543
srcs = ["logic.proto"],
@@ -69,6 +77,11 @@ proto_library(
6977
]
7078
)
7179

80+
proto_library(
81+
name = "version-proto",
82+
srcs = ["version.proto"],
83+
)
84+
7285
# TODO: THIS SHOULD BE MADE TO STOP EXISTING
7386
# This exists to support the nodejs build- when it becomes a real rule, we should extract the .src_files
7487
# from the above proto_library rules, but for now this is required to get the source files.
@@ -77,11 +90,13 @@ filegroup(
7790
srcs = [
7891
"answer.proto",
7992
"concept.proto",
93+
"connection.proto",
8094
"options.proto",
8195
"query.proto",
8296
"session.proto",
8397
"transaction.proto",
8498
"logic.proto",
99+
"version.proto",
85100
]
86101
)
87102

common/connection.proto

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// Copyright (C) 2022 Vaticle
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as
6+
// published by the Free Software Foundation, either version 3 of the
7+
// License, or (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
//
17+
18+
syntax = "proto3";
19+
20+
option java_package = "com.vaticle.typedb.protocol";
21+
option java_outer_classname = "ConnectionProto";
22+
option java_generic_services = true;
23+
24+
import "common/version.proto";
25+
26+
package typedb.protocol;
27+
28+
message Connection {
29+
30+
message Open {
31+
message Req {
32+
Version version = 1;
33+
}
34+
35+
message Res {}
36+
}
37+
}

common/version.proto

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//
2+
// Copyright (C) 2022 Vaticle
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as
6+
// published by the Free Software Foundation, either version 3 of the
7+
// License, or (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
//
17+
18+
syntax = "proto3";
19+
20+
option java_package = "com.vaticle.typedb.protocol";
21+
option java_outer_classname = "VersionProto";
22+
option java_generic_services = true;
23+
24+
package typedb.protocol;
25+
26+
enum Version {
27+
// reserved; // add past version numbers into the reserved range
28+
UNSPECIFIED = 0;
29+
VERSION = 1;
30+
}

core/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ proto_library(
2929
srcs = ["core_service.proto"],
3030
deps = [
3131
"//core:database-proto",
32+
"//common:connection-proto",
3233
"//common:session-proto",
3334
"//common:transaction-proto",
3435
],

core/core_service.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ option java_outer_classname = "CoreServiceProto";
2222
option java_generic_services = true;
2323

2424
import "core/core_database.proto";
25+
import "common/connection.proto";
2526
import "common/session.proto";
2627
import "common/transaction.proto";
2728

2829
package typedb.protocol;
2930

3031
service TypeDB {
3132

33+
// Connection API
34+
rpc connection_open (Connection.Open.Req) returns (Connection.Open.Res);
35+
3236
// Database Manager API
3337
rpc databases_contains (CoreDatabaseManager.Contains.Req) returns (CoreDatabaseManager.Contains.Res);
3438
rpc databases_create (CoreDatabaseManager.Create.Req) returns (CoreDatabaseManager.Create.Res);

grpc/java/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ java_grpc_compile(
3232
"//cluster:database-proto",
3333
"//common:answer-proto",
3434
"//common:concept-proto",
35+
"//common:connection-proto",
3536
"//common:logic-proto",
3637
"//common:options-proto",
3738
"//common:query-proto",
3839
"//common:session-proto",
3940
"//common:transaction-proto",
41+
"//common:version-proto",
4042
"//core:database-proto",
4143
"//core:service-proto",
4244
]

grpc/nodejs/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ ts_grpc_compile(
4747
"//cluster:service-proto", # TODO: do we need this?
4848
"//common:answer-proto",
4949
"//common:concept-proto",
50+
"//common:connection-proto",
5051
"//common:logic-proto",
5152
"//common:options-proto",
5253
"//common:query-proto",
5354
"//common:session-proto",
5455
"//common:transaction-proto",
56+
"//common:version-proto",
5557
"//core:database-proto",
5658
"//core:service-proto", # TODO: do we need this?
5759
],

grpc/python/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ python_grpc_compile(
3131
"//cluster:service-proto",
3232
"//common:answer-proto",
3333
"//common:concept-proto",
34+
"//common:connection-proto",
3435
"//common:logic-proto",
3536
"//common:options-proto",
3637
"//common:query-proto",
3738
"//common:session-proto",
3839
"//common:transaction-proto",
40+
"//common:version-proto",
3941
"//core:database-proto",
4042
"//core:service-proto",
4143
],

grpc/rust/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ rust_tonic_compile(
3131
"//cluster:database-proto",
3232
"//common:answer-proto",
3333
"//common:concept-proto",
34+
"//common:connection-proto",
3435
"//common:logic-proto",
3536
"//common:options-proto",
3637
"//common:query-proto",
3738
"//common:session-proto",
3839
"//common:transaction-proto",
40+
"//common:version-proto",
3941
"//core:database-proto",
4042
"//core:service-proto",
4143
]

0 commit comments

Comments
 (0)