Skip to content

Commit

Permalink
Introduce QueryRegion stream
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <[email protected]>
  • Loading branch information
JmPotato committed Oct 15, 2024
1 parent 4a3e17f commit dc598fd
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 2 deletions.
22 changes: 20 additions & 2 deletions pkg/configpb/configpb.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions proto/pdpb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ service PD {

rpc GetRegionByID(GetRegionByIDRequest) returns (GetRegionResponse) {}

rpc QueryRegion(stream QueryRegionRequest) returns (stream QueryRegionResponse) {}

// Deprecated: use BatchScanRegions instead.
rpc ScanRegions(ScanRegionsRequest) returns (ScanRegionsResponse) {}

Expand Down Expand Up @@ -334,6 +336,29 @@ message GetRegionByIDRequest {
bool need_buckets = 3;
}

message QueryRegionRequest {
RequestHeader header = 1;

bool need_buckets = 2;
repeated bytes region_keys = 3;
repeated uint64 region_ids = 4;
}

message QueryRegionResponse {
ResponseHeader header = 1;

map<bytes, RegionResponse> regions_by_key = 2;
map<uint64, RegionResponse> regions_by_id = 3;
}

message RegionResponse {
metapb.Region region = 1;
metapb.Peer leader = 2;
repeated PeerStats down_peers = 3;
repeated metapb.Peer pending_peers = 4;
metapb.Buckets buckets = 5;
}

// Use GetRegionResponse as the response of GetRegionByIDRequest.
// Deprecated: use BatchScanRegionsRequest instead.
message ScanRegionsRequest {
Expand Down
94 changes: 94 additions & 0 deletions scripts/proto.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14265,6 +14265,93 @@
}
]
},
{
"name": "QueryRegionRequest",
"fields": [
{
"id": 1,
"name": "header",
"type": "RequestHeader"
},
{
"id": 2,
"name": "need_buckets",
"type": "bool"
},
{
"id": 3,
"name": "region_keys",
"type": "bytes",
"is_repeated": true
},
{
"id": 4,
"name": "region_ids",
"type": "uint64",
"is_repeated": true
}
]
},
{
"name": "QueryRegionResponse",
"fields": [
{
"id": 1,
"name": "header",
"type": "ResponseHeader"
}
],
"maps": [
{
"key_type": "bytes",
"field": {
"id": 2,
"name": "regions_by_key",
"type": "RegionResponse"
}
},
{
"key_type": "uint64",
"field": {
"id": 3,
"name": "regions_by_id",
"type": "RegionResponse"
}
}
]
},
{
"name": "RegionResponse",
"fields": [
{
"id": 1,
"name": "region",
"type": "metapb.Region"
},
{
"id": 2,
"name": "leader",
"type": "metapb.Peer"
},
{
"id": 3,
"name": "down_peers",
"type": "PeerStats",
"is_repeated": true
},
{
"id": 4,
"name": "pending_peers",
"type": "metapb.Peer",
"is_repeated": true
},
{
"id": 5,
"name": "buckets",
"type": "metapb.Buckets"
}
]
},
{
"name": "ScanRegionsRequest",
"fields": [
Expand Down Expand Up @@ -16494,6 +16581,13 @@
"in_type": "GetRegionByIDRequest",
"out_type": "GetRegionResponse"
},
{
"name": "QueryRegion",
"in_type": "QueryRegionRequest",
"out_type": "QueryRegionResponse",
"in_streamed": true,
"out_streamed": true
},
{
"name": "ScanRegions",
"in_type": "ScanRegionsRequest",
Expand Down

0 comments on commit dc598fd

Please sign in to comment.