feat: add grpc impl (#50)

* feat: add grpc impl

* feat: add grpc server

* some ut

* verson format: a.b

* code style

* admin request/response

* by cr

* admin api

* by cr

* chore: by cr

* chore: by cr
This commit is contained in:
Jiachun Feng
2022-07-06 20:56:16 +08:00
committed by GitHub
parent 008f62afc1
commit 6cf1da35ee
23 changed files with 524 additions and 10 deletions

13
src/api/Cargo.toml Normal file
View File

@@ -0,0 +1,13 @@
[package]
name = "api"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
prost = "0.10"
tonic = "0.7"
[build-dependencies]
tonic-build = "0.7"

5
src/api/build.rs Normal file
View File

@@ -0,0 +1,5 @@
fn main() {
tonic_build::configure()
.compile(&["greptime/v1/greptime.proto"], &["."])
.expect("compile proto");
}

View File

@@ -0,0 +1,9 @@
syntax = "proto3";
package greptime.v1;
// TODO(jiachun)
message AdminRequest {}
// TODO(jiachun)
message AdminResponse {}

View File

@@ -0,0 +1,52 @@
syntax = "proto3";
package greptime.v1;
message DatabaseRequest {
string name = 1;
repeated ObjectExpr exprs = 2;
}
message DatabaseResponse {
repeated ObjectResult results = 1;
}
message ObjectExpr {
ExprHeader header = 1;
InsertExpr insert = 2;
SelectExpr select = 3;
UpdateExpr update = 4;
DeleteExpr delete = 5;
}
message SelectExpr {
string select = 1; // sql, promql, etc.
}
message InsertExpr {
string table_name = 1;
repeated bytes values = 2;
}
// TODO(jiachun)
message UpdateExpr {}
// TODO(jiachun)
message DeleteExpr {}
message ObjectResult {
ResultHeader header = 1;
string schema = 2;
repeated bytes results = 3;
}
message ExprHeader {
uint32 version = 1;
}
message ResultHeader {
uint32 version = 1;
uint32 success = 2;
uint32 failure = 3;
uint32 code = 4;
string err_msg = 5;
}

View File

@@ -0,0 +1,20 @@
syntax = "proto3";
package greptime.v1;
import "greptime/v1/admin.proto";
import "greptime/v1/database.proto";
service Greptime {
rpc Batch(BatchRequest) returns (BatchResponse) {}
}
message BatchRequest {
repeated AdminRequest admins = 1;
repeated DatabaseRequest databases = 2;
}
message BatchResponse {
repeated AdminResponse admins = 1;
repeated DatabaseResponse databases = 2;
}

1
src/api/src/lib.rs Normal file
View File

@@ -0,0 +1 @@
pub mod v1;

1
src/api/src/v1.rs Normal file
View File

@@ -0,0 +1 @@
tonic::include_proto!("greptime.v1");