Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add frontend heartbeat proto #27

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ fn main() {
"proto/greptime/v1/health.proto",
"proto/greptime/v1/meta/common.proto",
"proto/greptime/v1/meta/heartbeat.proto",
"proto/greptime/v1/meta/frontend_heartbeat.proto",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we merge this into heartbeat.proto?

"proto/greptime/v1/meta/route.proto",
"proto/greptime/v1/meta/store.proto",
"proto/greptime/v1/meta/lock.proto",
627 changes: 627 additions & 0 deletions go/greptime/v1/meta/frontend_heartbeat.pb.go

Large diffs are not rendered by default.

137 changes: 137 additions & 0 deletions go/greptime/v1/meta/frontend_heartbeat_grpc.pb.go
64 changes: 64 additions & 0 deletions proto/greptime/v1/meta/frontend_heartbeat.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
syntax = "proto3";

package greptime.v1.meta;

option go_package = "github.com/GreptimeTeam/greptime-proto/go/greptime/v1/meta";

import "greptime/v1/meta/common.proto";

// Heartbeat service
//
// Heartbeat data is reported to meta by frontend at a certain frequency.
// In addition, Hearbeatreponse will contain some instructions issued by meta.
service FrontendHeartbeat {
rpc FrontendHeartbeat(stream FrontendHeartbeatRequest) returns (stream FrontendHeartbeatResponse) {}
}

message FrontendHeartbeatRequest {
RequestHeader header = 1;

// Self peer
Peer peer = 2;
// Actually reported time interval
TimeInterval report_interval = 3;
// Node stat
FrontendStat stat = 4;
}

message FrontendStat {
int64 rcus = 1;
int64 wcus = 2;
double cpu_usage = 3;
double load = 4;
}

message FrontendHeartbeatResponse {
ResponseHeader header = 1;

repeated Instruction instruction_list = 2;
}

// The instruction sent to frontend from meta.
message Instruction {
oneof payload {
InvalidateCache invalid_cache = 1;
}
}


// An instruction to invalidate the catalog cache in frontend.
//
// When level = CATALOG, frontend needs to invalidate all caches under the catalog_name.
// When level = SCHEMA, frontend needs to invalidate all caches under the schema_name.
// When level = TABLE, frontend needs to invalidate all caches under the table_name.
message InvalidateCache {
enum Level {
CATALOG = 0;
SCHEMA = 1;
TABLE = 2;
}
Level level = 1;
string catalog_name = 2;
string schema_name = 3;
string table_name = 4;
}
11 changes: 11 additions & 0 deletions src/v1/meta.rs
Original file line number Diff line number Diff line change
@@ -120,6 +120,16 @@ impl Error {
}
}

impl FrontendHeartbeatResponse {
#[inline]
pub fn is_not_leader(&self) -> bool {
if let Some(header) = &self.header {
return header.is_not_leader();
}
false
}
}

impl HeartbeatResponse {
#[inline]
pub fn is_not_leader(&self) -> bool {
@@ -142,6 +152,7 @@ macro_rules! gen_set_header {
}

gen_set_header!(HeartbeatRequest);
gen_set_header!(FrontendHeartbeatRequest);
gen_set_header!(RouteRequest);
gen_set_header!(CreateRequest);
gen_set_header!(RangeRequest);