Skip to content

Commit

Permalink
feat: support API definition & circuitbreak rule support multiple blo…
Browse files Browse the repository at this point in the history
…ckConfigs (#111)
  • Loading branch information
andrewshan authored Jul 19, 2024
1 parent 4a298f3 commit e175427
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
30 changes: 25 additions & 5 deletions api/v1/fault_tolerance/circuitbreaker.proto
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ message RuleMatcher {
message DestinationService {
string service = 1;
string namespace = 2;
MatchString method = 3;
// deprecated_filed using api.path in blockConfig instead
MatchString method = 3 [deprecated = true];
}
SourceService source = 1;
DestinationService destination = 2;
Expand Down Expand Up @@ -268,10 +269,10 @@ message CircuitBreakerRule {
Level level = 21;
// match condition for this rule
RuleMatcher rule_matcher = 22;
// error conditions to judge an invocation as an error
repeated ErrorCondition error_conditions = 23;
// trigger condition to trigger circuitbreaking
repeated TriggerCondition trigger_condition = 24;
// deprecated_filed error conditions to judge an invocation as an error
repeated ErrorCondition error_conditions = 23 [deprecated = true];
// deprecated_filed trigger condition to trigger circuitbreaking
repeated TriggerCondition trigger_condition = 24 [deprecated = true];
// the maximum % of an upstream cluster that can be ejected
uint32 max_ejection_percent = 25;
// recover condition to make resource open to close
Expand All @@ -280,6 +281,10 @@ message CircuitBreakerRule {
FaultDetectConfig faultDetectConfig = 27;
// fall back configuration
FallbackConfig fallbackConfig = 28;
// list for block configuration
repeated BlockConfig block_configs = 29 [ json_name = "block_configs" ];
// priority rules priority
uint32 priority = 30 [ json_name = "priority" ];
}

// the condition to judge an input invocation as an error
Expand Down Expand Up @@ -307,22 +312,26 @@ message TriggerCondition {
uint32 minimum_request = 5;
}

// circuitbreaking OPEN status recover
message RecoverCondition {
// seconds from open to half-open
uint32 sleep_window = 1;
// consecutive success request to recover
uint32 consecutiveSuccess = 2;
}

// fault detect config within circuitbreaking
message FaultDetectConfig {
bool enable = 1;
}

// fallback config
message FallbackConfig {
bool enable = 1;
FallbackResponse response = 2;
}

// fallback response
message FallbackResponse {
int32 code = 1;
message MessageHeader {
Expand All @@ -331,4 +340,15 @@ message FallbackResponse {
}
repeated MessageHeader headers = 2;
string body = 3;
}

// blocking strategy
message BlockConfig {
string name = 1 [ json_name = "name" ];
// blocking target api
API api = 2 [ json_name = "api" ];
// conditions to judge an invocation as an error
repeated ErrorCondition error_conditions = 3 [ json_name = "error_conditions" ];
// trigger condition to trigger circuitbreaking
repeated TriggerCondition trigger_conditions = 4 [ json_name = "trigger_conditions" ];
}
6 changes: 5 additions & 1 deletion api/v1/fault_tolerance/fault_detector.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ message FaultDetectRule {
message DestinationService {
string service = 1;
string namespace = 2;
MatchString method = 3;
// deprecated_filed use api.path instead
MatchString method = 3 [deprecated = true];
API api = 4;
}
// detect target
DestinationService target_service = 21;
Expand All @@ -60,6 +62,8 @@ message FaultDetectRule {
TcpProtocolConfig tcp_config = 27;
// udp detect config
UdpProtocolConfig udp_config = 28;
// priority rules priority
uint32 priority = 29 [ json_name = "priority" ];
}

message HttpProtocolConfig {
Expand Down
10 changes: 10 additions & 0 deletions api/v1/model/model.proto
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,13 @@ message ClientLabel {
string key = 1;
MatchString value = 2;
}

// API统一数据结构
message API {
// API的协议,*或者为空代表全部
string protocol = 1 [ json_name = "protocol" ];
// API的方法,*或者为空代表全部
string method = 2 [ json_name = "method" ];
// API的路径,支持多种匹配方式
MatchString path = 3 [ json_name = "path" ];
}
10 changes: 6 additions & 4 deletions api/v1/traffic_manage/routing.proto
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ message NearbyRoutingConfig {
// RuleRoutingConfig routing configuration
message RuleRoutingConfig {
// source source info
// deprecated: only for compatible to the old version server
repeated SourceService sources = 1;
// deprecated_filed only for compatible to the old version server
repeated SourceService sources = 1 [deprecated = true];
// destination destinations info
// deprecated: only for compatible to the old version server
repeated DestinationGroup destinations = 2;
// deprecated_filed only for compatible to the old version server
repeated DestinationGroup destinations = 2 [deprecated = true];
// rule route chain
repeated SubRuleRouting rules = 3;
}
Expand Down Expand Up @@ -260,6 +260,8 @@ message SourceMatch {
PATH = 5;
// cookie match http cookie
COOKIE = 6;
// indicate the caller instance metadata
CALLER_METADATA = 7;
}
Type type = 1;
// header key or query key
Expand Down

0 comments on commit e175427

Please sign in to comment.