diff --git a/grpc/java/BUILD b/grpc/java/BUILD index cf6f2316..b35e96a0 100644 --- a/grpc/java/BUILD +++ b/grpc/java/BUILD @@ -3,28 +3,34 @@ # file, You can obtain one at https://mozilla.org/MPL/2.0/. package(default_visibility = ["//visibility:public"]) + load("@typedb_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") load("@rules_proto_grpc//java:defs.bzl", "java_grpc_library") java_grpc_library( name = "typedb-protocol", protos = [ - "//proto:typedb-service", - "//proto:server-proto", - "//proto:user-proto", - "//proto:database-proto", - "//proto:migration-proto", - "//proto:error-proto", - "//proto:answer-proto", - "//proto:concept-proto", - "//proto:connection-proto", - "//proto:authentication-proto", - "//proto:options-proto", - "//proto:query-proto", - "//proto:transaction-proto", - "//proto:analyze-proto", - "//proto:analyzed-conjunction-proto", "//proto:version-proto", + "//proto/raft_service:raft-service", + "//proto/raft_service:replication-proto", + "//proto/raft_service:request-proto", + "//proto/typedb_clustering_service:typedb-clustering-proto", + "//proto/typedb_clustering_service:typedb-clustering-service", + "//proto/typedb_service:analyze-proto", + "//proto/typedb_service:analyzed-conjunction-proto", + "//proto/typedb_service:answer-proto", + "//proto/typedb_service:authentication-proto", + "//proto/typedb_service:concept-proto", + "//proto/typedb_service:connection-proto", + "//proto/typedb_service:database-proto", + "//proto/typedb_service:error-proto", + "//proto/typedb_service:migration-proto", + "//proto/typedb_service:options-proto", + "//proto/typedb_service:query-proto", + "//proto/typedb_service:server-proto", + "//proto/typedb_service:transaction-proto", + "//proto/typedb_service:typedb-service", + "//proto/typedb_service:user-proto", ], # TypeDB Core bundles JARs by maven coordinate, we can remove this when Core is rewritten in Rust tags = ["maven_coordinates=com.typedb:typedb-protocol:{pom_version}"], @@ -32,7 +38,7 @@ java_grpc_library( checkstyle_test( name = "checkstyle", + size = "small", include = glob(["*"]), license_type = "mpl-header", - size = "small", ) diff --git a/grpc/nodejs/BUILD b/grpc/nodejs/BUILD index c9b88271..4db32940 100644 --- a/grpc/nodejs/BUILD +++ b/grpc/nodejs/BUILD @@ -3,6 +3,7 @@ # file, You can obtain one at https://mozilla.org/MPL/2.0/. package(default_visibility = ["//visibility:public"]) + load("@typedb_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") load("@typedb_bazel_distribution//npm:rules.bzl", "assemble_npm", "deploy_npm") load("@typedb_dependencies//distribution:deployment.bzl", "deployment") @@ -14,7 +15,10 @@ load("//grpc/nodejs:rules.bzl", "ts_grpc_compile") npm_link_all_packages(name = "node_modules") -exports_files(["package.json", "pnpm-lock.yaml"]) +exports_files([ + "package.json", + "pnpm-lock.yaml", +]) load("@typedb_protocol_npm//grpc/nodejs:protoc-gen-ts/package_json.bzl", protoc_gen_ts_bin = "bin") @@ -25,28 +29,35 @@ protoc_gen_ts_bin.protoc_gen_ts_binary( ts_grpc_compile( name = "typedb-protocol-src", deps = [ - "//proto:typedb-service", - "//proto:server-proto", - "//proto:user-proto", - "//proto:database-proto", - "//proto:migration-proto", - "//proto:error-proto", - "//proto:answer-proto", - "//proto:concept-proto", - "//proto:connection-proto", - "//proto:authentication-proto", - "//proto:options-proto", - "//proto:query-proto", - "//proto:transaction-proto", - "//proto:analyze-proto", - "//proto:analyzed-conjunction-proto", "//proto:version-proto", - ] + "//proto/raft_service:raft-service", + "//proto/raft_service:replication-proto", + "//proto/raft_service:request-proto", + "//proto/typedb_clustering_service:typedb-clustering-proto", + "//proto/typedb_clustering_service:typedb-clustering-service", + "//proto/typedb_service:analyze-proto", + "//proto/typedb_service:analyzed-conjunction-proto", + "//proto/typedb_service:answer-proto", + "//proto/typedb_service:authentication-proto", + "//proto/typedb_service:concept-proto", + "//proto/typedb_service:connection-proto", + "//proto/typedb_service:database-proto", + "//proto/typedb_service:error-proto", + "//proto/typedb_service:migration-proto", + "//proto/typedb_service:options-proto", + "//proto/typedb_service:query-proto", + "//proto/typedb_service:server-proto", + "//proto/typedb_service:transaction-proto", + "//proto/typedb_service:typedb-service", + "//proto/typedb_service:user-proto", + ], ) ts_project( name = "typedb-protocol", srcs = [":typedb-protocol-src"], + declaration = True, + transpiler = "tsc", tsconfig = { "compilerOptions": { "target": "es2019", @@ -56,26 +67,27 @@ ts_project( }, "include": [ "proto", - ] + ], }, - declaration = True, + visibility = ["//visibility:public"], deps = [ ":node_modules/@grpc/grpc-js", - ":node_modules/google-protobuf", ":node_modules/@types/google-protobuf", ":node_modules/@types/node", + ":node_modules/google-protobuf", ":node_modules/typescript", ], - transpiler = "tsc", - visibility = ["//visibility:public"], ) npm_package( name = "typedb-protocol-package", - srcs = [":typedb-protocol", "package.json"], + srcs = [ + "package.json", + ":typedb-protocol", + ], + include_external_repositories = ["typedb_protocol"], include_runfiles = False, package = "typedb-protocol", - include_external_repositories = ["typedb_protocol"], visibility = ["//visibility:public"], ) @@ -86,18 +98,18 @@ assemble_npm( deploy_npm( name = "deploy-npm", - target = ":assemble-npm", - snapshot = deployment["npm"]["snapshot"], release = deployment["npm"]["release"], + snapshot = deployment["npm"]["snapshot"], + target = ":assemble-npm", ) checkstyle_test( name = "checkstyle", + size = "small", include = glob(["*"]), exclude = [ "package.json", "pnpm-lock.yaml", ], license_type = "mpl-header", - size = "small", ) diff --git a/grpc/rust/BUILD b/grpc/rust/BUILD index d3e84fe6..c3f05955 100644 --- a/grpc/rust/BUILD +++ b/grpc/rust/BUILD @@ -10,64 +10,69 @@ load("@typedb_dependencies//builder/proto_grpc/rust:compile.bzl", "rust_tonic_co rust_tonic_compile( name = "typedb_protocol_src", - packages = ["typedb.protocol"], srcs = [ - "//proto:typedb-service", - "//proto:server-proto", - "//proto:user-proto", - "//proto:database-proto", - "//proto:migration-proto", - "//proto:error-proto", - "//proto:answer-proto", - "//proto:concept-proto", - "//proto:connection-proto", - "//proto:authentication-proto", - "//proto:options-proto", - "//proto:query-proto", - "//proto:transaction-proto", - "//proto:analyze-proto", - "//proto:analyzed-conjunction-proto", "//proto:version-proto", - ] + "//proto/raft_service:raft-service", + "//proto/raft_service:replication-proto", + "//proto/raft_service:request-proto", + "//proto/typedb_clustering_service:typedb-clustering-proto", + "//proto/typedb_clustering_service:typedb-clustering-service", + "//proto/typedb_service:analyze-proto", + "//proto/typedb_service:analyzed-conjunction-proto", + "//proto/typedb_service:answer-proto", + "//proto/typedb_service:authentication-proto", + "//proto/typedb_service:concept-proto", + "//proto/typedb_service:connection-proto", + "//proto/typedb_service:database-proto", + "//proto/typedb_service:error-proto", + "//proto/typedb_service:migration-proto", + "//proto/typedb_service:options-proto", + "//proto/typedb_service:query-proto", + "//proto/typedb_service:server-proto", + "//proto/typedb_service:transaction-proto", + "//proto/typedb_service:typedb-service", + "//proto/typedb_service:user-proto", + ], + packages = ["typedb.protocol"], ) rust_library( name = "typedb_protocol", - crate_root = ":typedb_protocol_src", srcs = [ ":typedb_protocol_src", ], - deps = [ - "@crates//:tonic", - "@crates//:prost", - ], + crate_root = ":typedb_protocol_src", tags = [ "crate-name=typedb-protocol", ], visibility = ["//visibility:public"], + deps = [ + "@crates//:prost", + "@crates//:tonic", + ], ) assemble_crate( name = "assemble_crate", - target = ":typedb_protocol", description = "TypeDB Protocol", homepage = "https://github.com/typedb/typedb-protocol", - readme_file = "//:README.md", license = "MPL-2.0", license_file = "//:LICENSE", + readme_file = "//:README.md", repository = "https://github.com/typedb/typedb-protocol", + target = ":typedb_protocol", ) deploy_crate( name = "deploy_crate", - target = ":assemble_crate", + release = deployment["crate"]["release"], snapshot = deployment["crate"]["snapshot"], - release = deployment["crate"]["release"] + target = ":assemble_crate", ) checkstyle_test( name = "checkstyle", + size = "small", include = glob(["*"]), license_type = "mpl-header", - size = "small", ) diff --git a/grpc/rust/build.rs b/grpc/rust/build.rs index 8ea60f8f..8ba15f05 100644 --- a/grpc/rust/build.rs +++ b/grpc/rust/build.rs @@ -4,21 +4,25 @@ fn main() -> std::io::Result<()> { let protos = vec![ - "../../proto/analyze.proto", - "../../proto/answer.proto", - "../../proto/authentication.proto", - "../../proto/concept.proto", - "../../proto/connection.proto", - "../../proto/analyzed-conjunction.proto", - "../../proto/database.proto", - "../../proto/error.proto", - "../../proto/migration.proto", - "../../proto/options.proto", - "../../proto/query.proto", - "../../proto/server.proto", - "../../proto/transaction.proto", - "../../proto/typedb-service.proto", - "../../proto/user.proto", + "../../proto/raft_service/replication.proto", + "../../proto/raft_service/raft_service.proto", + "../../proto/typedb_clustering_service/typedb_clustering.proto", + "../../proto/typedb_clustering_service/typedb_clustering_service.proto", + "../../proto/typedb_service/analyze.proto", + "../../proto/typedb_service/analyzed-conjunction.proto", + "../../proto/typedb_service/answer.proto", + "../../proto/typedb_service/authentication.proto", + "../../proto/typedb_service/concept.proto", + "../../proto/typedb_service/connection.proto", + "../../proto/typedb_service/database.proto", + "../../proto/typedb_service/error.proto", + "../../proto/typedb_service/migration.proto", + "../../proto/typedb_service/options.proto", + "../../proto/typedb_service/query.proto", + "../../proto/typedb_service/server.proto", + "../../proto/typedb_service/transaction.proto", + "../../proto/typedb_service/typedb_service.proto", + "../../proto/typedb_service/user.proto", "../../proto/version.proto", ]; diff --git a/proto/BUILD b/proto/BUILD index 1eaa241b..3b6d63bf 100644 --- a/proto/BUILD +++ b/proto/BUILD @@ -6,125 +6,6 @@ package(default_visibility = ["//visibility:public"]) load("@typedb_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") -proto_library( - name = "typedb-service", - srcs = [":typedb-service.proto"], - deps = [ - ":connection-proto", - ":authentication-proto", - ":server-proto", - ":user-proto", - ":database-proto", - ":transaction-proto", - ":migration-proto", - ], -) - -proto_library( - name = "server-proto", - srcs = [":server.proto"], -) - -proto_library( - name = "database-proto", - srcs = [":database.proto"], - deps = [ - ":migration-proto", - ], -) - -proto_library( - name = "migration-proto", - srcs = [":migration.proto"], - deps = [":concept-proto"], -) - -proto_library( - name = "user-proto", - srcs = [":user.proto"], -) - -proto_library( - name = "answer-proto", - srcs = ["answer.proto"], - deps = [":concept-proto"], -) - -proto_library( - name = "authentication-proto", - srcs = ["authentication.proto"], -) - -proto_library( - name = "concept-proto", - srcs = ["concept.proto"], -) - -proto_library( - name = "connection-proto", - srcs = ["connection.proto"], - deps = [ - ":authentication-proto", - ":database-proto", - ":version-proto" - ], -) - -proto_library( - name = "options-proto", - srcs = ["options.proto"], -) - -proto_library( - name = "query-proto", - srcs = ["query.proto"], - deps = [ - ":analyze-proto", - ":answer-proto", - ":concept-proto", - ":error-proto", - ":options-proto", - ], -) - -proto_library( - name = "error-proto", - srcs = ["error.proto"], -) - -proto_library( - name = "transaction-proto", - srcs = ["transaction.proto"], - deps = [ - ":analyze-proto", - ":answer-proto", - ":concept-proto", - ":error-proto", - ":options-proto", - ":query-proto", - ] -) - -proto_library( - name = "analyze-proto", - srcs = ["analyze.proto"], - deps = [ - ":analyzed-conjunction-proto", - ":concept-proto", - ":error-proto", - ":options-proto", - ], -) - -proto_library( - name = "analyzed-conjunction-proto", - srcs = ["analyzed-conjunction.proto"], - deps = [ - ":answer-proto", - ":concept-proto", - ], -) - proto_library( name = "version-proto", srcs = ["version.proto"], @@ -136,21 +17,21 @@ proto_library( filegroup( name = "proto-raw-buffers", srcs = [ - "analyze.proto", - "answer.proto", - "concept.proto", - "connection.proto", - "analyzed-conjunction.proto", - "options.proto", - "query.proto", - "transaction.proto", + "//proto/typedb_service:analyze.proto", + "//proto/typedb_service:analyzed-conjunction.proto", + "//proto/typedb_service:answer.proto", + "//proto/typedb_service:concept.proto", + "//proto/typedb_service:connection.proto", + "//proto/typedb_service:options.proto", + "//proto/typedb_service:query.proto", + "//proto/typedb_service:transaction.proto", "version.proto", - ] + ], ) checkstyle_test( name = "checkstyle", + size = "small", include = glob(["*"]), license_type = "mpl-header", - size = "small", ) diff --git a/proto/raft_service/BUILD b/proto/raft_service/BUILD new file mode 100644 index 00000000..c9fc4f22 --- /dev/null +++ b/proto/raft_service/BUILD @@ -0,0 +1,35 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. + +package(default_visibility = ["//visibility:public"]) + +load("@typedb_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") + +proto_library( + name = "raft-service", + srcs = ["raft_service.proto"], + deps = [ + ":replication-proto", + ":request-proto", + ], +) + +proto_library( + name = "replication-proto", + srcs = ["replication.proto"], + deps = [], +) + +proto_library( + name = "request-proto", + srcs = ["request.proto"], + deps = [], +) + +checkstyle_test( + name = "checkstyle", + size = "small", + include = glob(["*"]), + license_type = "mpl-header", +) diff --git a/proto/raft_service/raft_service.proto b/proto/raft_service/raft_service.proto new file mode 100644 index 00000000..d9346878 --- /dev/null +++ b/proto/raft_service/raft_service.proto @@ -0,0 +1,16 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +syntax = "proto3"; + +import "proto/raft_service/replication.proto"; +import "proto/raft_service/request.proto"; + +package typedb.protocol; + +// TODO: If the protocol is exposed, maybe it's actually `TypeDBRaft`? +service Raft { + rpc replication (Replication.Req) returns (Replication.Res); + rpc request (Request) returns (Request); +} diff --git a/proto/server.proto b/proto/raft_service/replication.proto similarity index 58% rename from proto/server.proto rename to proto/raft_service/replication.proto index 40d2c989..7d9dc921 100644 --- a/proto/server.proto +++ b/proto/raft_service/replication.proto @@ -6,16 +6,12 @@ syntax = "proto3"; package typedb.protocol; -message ServerManager { - - message All { - message Req {} - message Res { - repeated Server servers = 1; - } +message Replication { + message Req { + uint64 from_id = 1; + string from_address = 2; + bytes message = 3; } -} -message Server { - string address = 1; + message Res {} } diff --git a/proto/raft_service/request.proto b/proto/raft_service/request.proto new file mode 100644 index 00000000..294d24a0 --- /dev/null +++ b/proto/raft_service/request.proto @@ -0,0 +1,131 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +syntax = "proto3"; + +package typedb.protocol; + +message Request { + oneof request { + Load load = 1; + DatabaseManager database_manager = 2; + Database database = 3; + UserManager user_manager = 4; + User user = 5; + } + + message Load {} + + message DatabaseManager { + oneof database_manager { + All all = 1; + Contains contains = 2; + Get get = 3; + GetUnrestricted get_unrestricted = 4; + Create create = 5; + CreateUnrestricted create_unrestricted = 6; + } + + message All {} + + message Contains { + string name = 1; + } + + message Get { + string name = 1; + } + + message GetUnrestricted { + string name = 1; + } + message Create { + string name = 1; + } + + message CreateUnrestricted { + string name = 1; + } + } + + message Database { + oneof database { + Schema schema = 1; + TypeSchema type_schema = 2; + SchemaCommit schema_commit = 3; + DataCommit data_commit = 4; + Delete delete = 5; + } + + message Schema { + string name = 1; + } + + message TypeSchema { + string name = 1; + } + + message SchemaCommit { + string name = 1; + bytes commit_record = 2; + } + + message DataCommit { + string name = 1; + bytes commit_record = 2; + } + + message Delete { + string name = 1; + } + } + + message UserManager { + oneof user_manager { + All all = 1; + Contains contains = 2; + Get get = 3; + Create create = 4; + } + + message All { + string accessor = 1; + } + + message Contains { + string name = 1; + string accessor = 2; + } + + message Get { + string name = 1; + string accessor = 2; + } + + message Create { + string name = 1; + string password_hash = 2; + string accessor = 3; + } + } + + message User { + oneof user { + Update update = 1; + Delete delete = 2; + } + + message Update { + string name = 1; + optional string name_update = 2; + optional string password_hash_update = 3; + string accessor = 4; + } + + message Delete { + string name = 1; + string accessor = 2; + } + } +} diff --git a/proto/typedb_clustering_service/BUILD b/proto/typedb_clustering_service/BUILD new file mode 100644 index 00000000..4a5caf09 --- /dev/null +++ b/proto/typedb_clustering_service/BUILD @@ -0,0 +1,30 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. + +package(default_visibility = ["//visibility:public"]) + +load("@typedb_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") + +proto_library( + name = "typedb-clustering-service", + srcs = ["typedb_clustering_service.proto"], + deps = [ + ":typedb-clustering-proto", + ], +) + +proto_library( + name = "typedb-clustering-proto", + srcs = ["typedb_clustering.proto"], + deps = [ + "//proto/typedb_service:server-proto", + ], +) + +checkstyle_test( + name = "checkstyle", + size = "small", + include = glob(["*"]), + license_type = "mpl-header", +) diff --git a/proto/typedb_clustering_service/typedb_clustering.proto b/proto/typedb_clustering_service/typedb_clustering.proto new file mode 100644 index 00000000..74ab151a --- /dev/null +++ b/proto/typedb_clustering_service/typedb_clustering.proto @@ -0,0 +1,25 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +syntax = "proto3"; + +package typedb.protocol; + +import "proto/typedb_service/server.proto"; + +message CanRegister { + message Req { + uint64 replica_id = 1; + } + + message Res {} +} + +message ServerStatus { + message Req {} + + message Res { + Server server = 1; + } +} diff --git a/proto/typedb_clustering_service/typedb_clustering_service.proto b/proto/typedb_clustering_service/typedb_clustering_service.proto new file mode 100644 index 00000000..cc83c61a --- /dev/null +++ b/proto/typedb_clustering_service/typedb_clustering_service.proto @@ -0,0 +1,14 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +syntax = "proto3"; + +import "proto/typedb_clustering_service/typedb_clustering.proto"; + +package typedb.protocol; + +service TypeDBClustering { + rpc can_register (CanRegister.Req) returns (CanRegister.Res); + rpc server_status (ServerStatus.Req) returns (ServerStatus.Res); +} diff --git a/proto/typedb_service/BUILD b/proto/typedb_service/BUILD new file mode 100644 index 00000000..7246b159 --- /dev/null +++ b/proto/typedb_service/BUILD @@ -0,0 +1,134 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. + +package(default_visibility = ["//visibility:public"]) + +load("@typedb_dependencies//tool/checkstyle:rules.bzl", "checkstyle_test") + +proto_library( + name = "typedb-service", + srcs = ["typedb_service.proto"], + deps = [ + ":authentication-proto", + ":connection-proto", + ":database-proto", + ":migration-proto", + ":server-proto", + ":transaction-proto", + ":user-proto", + ], +) + +proto_library( + name = "analyze-proto", + srcs = ["analyze.proto"], + deps = [ + ":analyzed-conjunction-proto", + ":concept-proto", + ":error-proto", + ":options-proto", + ], +) + +proto_library( + name = "analyzed-conjunction-proto", + srcs = ["analyzed-conjunction.proto"], + deps = [ + ":answer-proto", + ":concept-proto", + ], +) + +proto_library( + name = "answer-proto", + srcs = ["answer.proto"], + deps = [":concept-proto"], +) + +proto_library( + name = "authentication-proto", + srcs = ["authentication.proto"], +) + +proto_library( + name = "concept-proto", + srcs = ["concept.proto"], +) + +proto_library( + name = "connection-proto", + srcs = ["connection.proto"], + deps = [ + ":authentication-proto", + ":database-proto", + ":server-proto", + "//proto:version-proto", + ], +) + +proto_library( + name = "database-proto", + srcs = ["database.proto"], + deps = [ + ":migration-proto", + ], +) + +proto_library( + name = "error-proto", + srcs = ["error.proto"], +) + +proto_library( + name = "migration-proto", + srcs = ["migration.proto"], + deps = [":concept-proto"], +) + +proto_library( + name = "options-proto", + srcs = ["options.proto"], +) + +proto_library( + name = "query-proto", + srcs = ["query.proto"], + deps = [ + ":analyze-proto", + ":answer-proto", + ":concept-proto", + ":error-proto", + ":options-proto", + ], +) + +proto_library( + name = "server-proto", + srcs = ["server.proto"], +) + +proto_library( + name = "transaction-proto", + srcs = ["transaction.proto"], + deps = [ + ":analyze-proto", + ":answer-proto", + ":concept-proto", + ":error-proto", + ":options-proto", + ":query-proto", + ], +) + +proto_library( + name = "user-proto", + srcs = ["user.proto"], +) + +checkstyle_test( + name = "checkstyle", + size = "small", + include = glob(["*"]), + license_type = "mpl-header", +) diff --git a/proto/analyze.proto b/proto/typedb_service/analyze.proto similarity index 95% rename from proto/analyze.proto rename to proto/typedb_service/analyze.proto index 7e3eb921..1d3dee84 100644 --- a/proto/analyze.proto +++ b/proto/typedb_service/analyze.proto @@ -4,10 +4,10 @@ syntax = "proto3"; -import "proto/analyzed-conjunction.proto"; -import "proto/concept.proto"; -import "proto/error.proto"; -import "proto/options.proto"; +import "proto/typedb_service/analyzed-conjunction.proto"; +import "proto/typedb_service/concept.proto"; +import "proto/typedb_service/error.proto"; +import "proto/typedb_service/options.proto"; package typedb.protocol; diff --git a/proto/analyzed-conjunction.proto b/proto/typedb_service/analyzed-conjunction.proto similarity index 97% rename from proto/analyzed-conjunction.proto rename to proto/typedb_service/analyzed-conjunction.proto index eef88d0f..a28f01e1 100644 --- a/proto/analyzed-conjunction.proto +++ b/proto/typedb_service/analyzed-conjunction.proto @@ -4,8 +4,8 @@ syntax = "proto3"; -import "proto/answer.proto"; -import "proto/concept.proto"; +import "proto/typedb_service/answer.proto"; +import "proto/typedb_service/concept.proto"; package typedb.protocol; diff --git a/proto/answer.proto b/proto/typedb_service/answer.proto similarity index 97% rename from proto/answer.proto rename to proto/typedb_service/answer.proto index 91d48174..2e88e544 100644 --- a/proto/answer.proto +++ b/proto/typedb_service/answer.proto @@ -4,7 +4,7 @@ syntax = "proto3"; -import "proto/concept.proto"; +import "proto/typedb_service/concept.proto"; package typedb.protocol; diff --git a/proto/authentication.proto b/proto/typedb_service/authentication.proto similarity index 100% rename from proto/authentication.proto rename to proto/typedb_service/authentication.proto diff --git a/proto/concept.proto b/proto/typedb_service/concept.proto similarity index 100% rename from proto/concept.proto rename to proto/typedb_service/concept.proto diff --git a/proto/connection.proto b/proto/typedb_service/connection.proto similarity index 76% rename from proto/connection.proto rename to proto/typedb_service/connection.proto index d288eb46..d4d3207d 100644 --- a/proto/connection.proto +++ b/proto/typedb_service/connection.proto @@ -4,37 +4,32 @@ syntax = "proto3"; -import "proto/authentication.proto"; -import "proto/database.proto"; +import "proto/typedb_service/authentication.proto"; +import "proto/typedb_service/database.proto"; +import "proto/typedb_service/server.proto"; import "proto/version.proto"; package typedb.protocol; message Connection { - message Open { message Req { Version version = 1; ExtensionVersion extension_version = 5; string driver_lang = 2; string driver_version = 3; - Authentication.Token.Create.Req authentication = 4; } message Res { uint64 server_duration_millis = 1; ConnectionID connection_id = 2; - - // pre-send all databases and replica info - DatabaseManager.All.Res databases_all = 3; - + ServerManager.All.Res servers_all = 3; Authentication.Token.Create.Res authentication = 4; } } } -// Connection ID and Token are expected in all message metadata message ConnectionID { bytes id = 1; } diff --git a/proto/database.proto b/proto/typedb_service/database.proto similarity index 81% rename from proto/database.proto rename to proto/typedb_service/database.proto index eefa6d4a..e3a2ca03 100644 --- a/proto/database.proto +++ b/proto/typedb_service/database.proto @@ -6,7 +6,7 @@ syntax = "proto3"; package typedb.protocol; -import "proto/migration.proto"; +import "proto/typedb_service/migration.proto"; message DatabaseManager { @@ -16,14 +16,14 @@ message DatabaseManager { } message Res { - DatabaseReplicas database = 1; + Database database = 1; } } message All { message Req {} message Res { - repeated DatabaseReplicas databases = 1; + repeated Database databases = 1; } } @@ -43,7 +43,7 @@ message DatabaseManager { } message Res { - DatabaseReplicas database = 1; + Database database = 1; } } @@ -58,20 +58,8 @@ message DatabaseManager { } } -message DatabaseReplicas { - - string name = 1; - repeated Replica replicas = 2; - - message Replica { - string address = 1; - bool primary = 2; - bool preferred = 3; - int64 term = 4; - } -} - message Database { + string name = 1; message Schema { message Req { diff --git a/proto/error.proto b/proto/typedb_service/error.proto similarity index 83% rename from proto/error.proto rename to proto/typedb_service/error.proto index eaa7a557..7543d286 100644 --- a/proto/error.proto +++ b/proto/typedb_service/error.proto @@ -7,7 +7,7 @@ syntax = "proto3"; package typedb.protocol; // This is an emulation of the google ErrorDetails message. Generally, ErrorDetails are submitted via the GRPC error -// mechanism, but a manual error sending is required in streams +// mechanism, but a manual error sending is useful to differentiate error levels in streams message Error { string error_code = 1; string domain = 2; diff --git a/proto/migration.proto b/proto/typedb_service/migration.proto similarity index 98% rename from proto/migration.proto rename to proto/typedb_service/migration.proto index 46ec24c2..ba82617e 100644 --- a/proto/migration.proto +++ b/proto/typedb_service/migration.proto @@ -6,7 +6,7 @@ syntax = "proto3"; package typedb.protocol; -import "proto/concept.proto"; +import "proto/typedb_service/concept.proto"; message Migration { message Export { diff --git a/proto/options.proto b/proto/typedb_service/options.proto similarity index 100% rename from proto/options.proto rename to proto/typedb_service/options.proto diff --git a/proto/query.proto b/proto/typedb_service/query.proto similarity index 92% rename from proto/query.proto rename to proto/typedb_service/query.proto index 8fd640b1..c8e13474 100644 --- a/proto/query.proto +++ b/proto/typedb_service/query.proto @@ -4,10 +4,10 @@ syntax = "proto3"; -import "proto/analyze.proto"; -import "proto/answer.proto"; -import "proto/options.proto"; -import "proto/error.proto"; +import "proto/typedb_service/analyze.proto"; +import "proto/typedb_service/answer.proto"; +import "proto/typedb_service/options.proto"; +import "proto/typedb_service/error.proto"; package typedb.protocol; diff --git a/proto/typedb_service/server.proto b/proto/typedb_service/server.proto new file mode 100644 index 00000000..fa524fa1 --- /dev/null +++ b/proto/typedb_service/server.proto @@ -0,0 +1,63 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +syntax = "proto3"; + +package typedb.protocol; + +message ServerManager { + message All { + message Req {} + message Res { + repeated Server servers = 1; + } + } + + message Get { + message Req {} + message Res { + Server server = 1; + } + } + + message Register { + message Req { + uint64 replica_id = 1; + string address = 2; + } + message Res {} + } + + message Deregister { + message Req { + uint64 replica_id = 1; + } + message Res {} + } +} + +message Server { + optional string address = 1; + optional ReplicaStatus replica_status = 2; + + message ReplicaStatus { + uint64 replica_id = 1; + optional ReplicaRole replica_role = 2; + optional uint64 term = 3; + + enum ReplicaRole { + Primary = 0; + Candidate = 1; + Secondary = 2; + } + } + + message Version { + message Req {} + message Res { + string distribution = 1; + string version = 2; + } + } +} diff --git a/proto/transaction.proto b/proto/typedb_service/transaction.proto similarity index 93% rename from proto/transaction.proto rename to proto/typedb_service/transaction.proto index ce5f648b..a47d07b7 100644 --- a/proto/transaction.proto +++ b/proto/typedb_service/transaction.proto @@ -4,10 +4,10 @@ syntax = "proto3"; -import "proto/analyze.proto"; -import "proto/error.proto"; -import "proto/options.proto"; -import "proto/query.proto"; +import "proto/typedb_service/analyze.proto"; +import "proto/typedb_service/error.proto"; +import "proto/typedb_service/options.proto"; +import "proto/typedb_service/query.proto"; package typedb.protocol; diff --git a/proto/typedb-service.proto b/proto/typedb_service/typedb_service.proto similarity index 77% rename from proto/typedb-service.proto rename to proto/typedb_service/typedb_service.proto index 95f0c239..2dec0f6b 100644 --- a/proto/typedb-service.proto +++ b/proto/typedb_service/typedb_service.proto @@ -4,13 +4,13 @@ syntax = "proto3"; -import "proto/authentication.proto"; -import "proto/connection.proto"; -import "proto/database.proto"; -import "proto/server.proto"; -import "proto/user.proto"; -import "proto/transaction.proto"; -import "proto/migration.proto"; +import "proto/typedb_service/authentication.proto"; +import "proto/typedb_service/connection.proto"; +import "proto/typedb_service/database.proto"; +import "proto/typedb_service/server.proto"; +import "proto/typedb_service/user.proto"; +import "proto/typedb_service/transaction.proto"; +import "proto/typedb_service/migration.proto"; package typedb.protocol; @@ -24,6 +24,12 @@ service TypeDB { // Server Manager API rpc servers_all (ServerManager.All.Req) returns (ServerManager.All.Res); + rpc servers_get (ServerManager.Get.Req) returns (ServerManager.Get.Res); + rpc servers_register(ServerManager.Register.Req) returns (ServerManager.Register.Res); + rpc servers_deregister(ServerManager.Deregister.Req) returns (ServerManager.Deregister.Res); + + // Server API + rpc server_version (Server.Version.Req) returns (Server.Version.Res); // User Manager API rpc users_get (UserManager.Get.Req) returns (UserManager.Get.Res); @@ -53,5 +59,4 @@ service TypeDB { // requests and responses back-and-forth. The first transaction client message must // be {Transaction.Open.Req}. Closing the stream closes the transaction. rpc transaction (stream Transaction.Client) returns (stream Transaction.Server); - } diff --git a/proto/user.proto b/proto/typedb_service/user.proto similarity index 100% rename from proto/user.proto rename to proto/typedb_service/user.proto