Skip to content

Commit

Permalink
feat: add lossless rule specification (#117)
Browse files Browse the repository at this point in the history
* feat: add ratelimit spec & remove temporary proto files

* Update version to 1.5.3-SNAPSHOT

* fix: change maxAmount to max_amount

* feat: add lossless rule specification
  • Loading branch information
andrewshan authored Aug 13, 2024
1 parent 99802f7 commit ea422dc
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/v1/service_manage/request.proto
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ message DiscoverRequest {
CUSTOM_ROUTE_RULE = 101;
// 就近路由规则
NEARBY_ROUTE_RULE = 102;
// 无损上下线规则
LOSSLESS = 103;
}

DiscoverRequestType type = 1;
Expand Down
5 changes: 5 additions & 0 deletions api/v1/service_manage/response.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import "fault_detector.proto";
import "auth.proto";
import "contract.proto";
import "lane.proto";
import "lossless.proto";

option go_package = "github.com/polarismesh/specification/source/go/api/v1/service_manage";
option java_package = "com.tencent.polaris.specification.api.v1.service.manage";
Expand Down Expand Up @@ -101,6 +102,8 @@ message DiscoverResponse {
CUSTOM_ROUTE_RULE = 101;
// 就近路由规则
NEARBY_ROUTE_RULE = 102;
// 无损上下线规则
LOSSLESS = 103;
}

DiscoverResponseType type = 3;
Expand All @@ -119,6 +122,8 @@ message DiscoverResponse {
repeated RouteRule customRouteRules = 23;
// 就近路由规则内容
repeated RouteRule nearbyRouteRules = 24;
// 无损上下线规则内容
LosslessRule losslessRule = 25;
}

message OptionSwitch { map<string, string> options = 1; }
Expand Down
86 changes: 86 additions & 0 deletions api/v1/traffic_manage/lossless.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
syntax = "proto3";

package v1;

import "google/protobuf/wrappers.proto";
import "google/protobuf/duration.proto";
import "model.proto";

option go_package = "github.com/polarismesh/specification/source/go/api/v1/traffic_manage";
option java_package = "com.tencent.polaris.specification.api.v1.traffic.manage";
option java_outer_classname = "LosslessProto";

// 优雅上下线规则的模型
message LosslessRule {
// rule id
string id = 1 [ json_name = "id" ];
// service for rule belongs to
string service = 2 [ json_name = "service" ];
// namespace for rule belongs to
string namespace = 3 [ json_name = "namespace" ];
// revision routing version
string revision = 4 [ json_name = "revision" ];
// ctime create time of the rules
string ctime = 5 [ json_name = "ctime" ];
// mtime modify time of the rules
string mtime = 6 [ json_name = "mtime" ];
// configuration for lossless online
LosslessOnline losslessOnline = 7 [ json_name = "lossless_online" ];
// configuration for lossless offline
LosslessOffline losslessOffline = 8 [ json_name = "lossless_offline" ];
}

message LosslessOnline {
// configuration for delayRegister
DelayRegister delayRegister = 1 [ json_name = "delay_register" ];
// configuration for warmup
Warmup warmup = 2 [ json_name = "warmup" ];
// configuration for readiness probe
Readiness readiness = 3 [ json_name = "readiness" ];
}

message DelayRegister {
// enable delay registry
bool enable = 1 [ json_name = "enable" ];
enum DelayStrategy {
// register instance after delay specific time
DELAY_BY_TIME = 0;
// register instance until health check successfully
DELAY_BY_HEALTH_CHECK = 1;
}
// delay register strategy
DelayStrategy strategy = 2 [ json_name = "strategy" ];
// delay register time by second, active when strategy == DELAY_BY_TIME
int32 intervalSecond = 3 [ json_name = "interval_second" ];
// protocol to do health check, default http, active when strategy == DELAY_BY_HEALTH_CHECK
string healthCheckProtocol = 4 [ json_name = "health_check_protocol" ];
// method to do health check, default GET, active when strategy == DELAY_BY_HEALTH_CHECK
string healthCheckMethod = 5 [ json_name = "health_check_method" ];
// path to do health check, no default value, active when strategy == DELAY_BY_HEALTH_CHECK
string healthCheckPath = 6 [ json_name = "health_check_path" ];
// health check interval second, default is 30, active when strategy == DELAY_BY_HEALTH_CHECK
string healthCheckIntervalSecond = 7 [ json_name = "health_check_interval_second" ];
}

message Warmup {
// enable warmup
bool enable = 1 [ json_name = "enable" ];
// total warmup interval by second
int32 intervalSecond = 2 [ json_name = "interval_second" ];
// warmup stop when most of the instances in service are in warmup status
bool enableOverloadProtection = 3 [ json_name = "enable_overload_protection" ];
// the threshold to active overload protection, default is 50, threshld = sum(WarmupInstances)/sum(AllInstances)*100
int32 overloadProtectionThreshold = 4 [ json_name = "overload_protection_threshold" ];
// curvature for warmup register, default is 1
int32 curvature = 5 [ json_name = "curvature" ];
}

message Readiness {
// enable /readiness expose
bool enable = 1 [ json_name = "enable" ];
}

message LosslessOffline {
// enable /offline expose
bool enable = 1 [ json_name = "enable" ];
}

0 comments on commit ea422dc

Please sign in to comment.