|
14 | 14 |
|
15 | 15 | syntax = "proto3"; |
16 | 16 |
|
17 | | -package io.opensergo.proto.faulttolerance.v1; |
| 17 | +package io.opensergo.proto.fault_tolerance.v1; |
18 | 18 |
|
19 | | -option java_package = "io.opensergo.proto.faulttolerance.v1"; |
| 19 | +option java_package = "io.opensergo.proto.fault_tolerance.v1"; |
20 | 20 | option java_outer_classname = "FaultToleranceProto"; |
21 | 21 | option java_multiple_files = true; |
22 | | -option go_package = "github.com/opensergo/opensergo-control-plane/proto/fault_tolerance/v1"; |
| 22 | +option go_package = "github.com/opensergo/opensergo-control-plane/pkg/proto/fault_tolerance/v1"; |
23 | 23 |
|
24 | 24 | import "common/v1/common.proto"; |
25 | 25 |
|
| 26 | +import "validate/validate.proto"; |
| 27 | + |
26 | 28 | // FaultToleranceRule |
| 29 | +message FaultToleranceRule { |
| 30 | + message FaultToleranceRuleTargetRef { |
| 31 | + string target_resource_name = 1; |
| 32 | + } |
27 | 33 |
|
28 | | -message FaultToleranceRuleTargetRef { |
29 | | - string target_resource_name = 1; |
30 | | -} |
| 34 | + message FaultToleranceStrategyRef { |
| 35 | + string name = 1; |
| 36 | + string kind = 2; |
| 37 | + } |
31 | 38 |
|
32 | | -message FaultToleranceStrategyRef { |
33 | | - string name = 1; |
34 | | - string kind = 2; |
35 | | -} |
36 | | - |
37 | | -message FaultToleranceActionRef { |
38 | | - string name = 1; |
39 | | - string kind = 2; |
40 | | -} |
| 39 | + message FaultToleranceActionRef { |
| 40 | + string name = 1; |
| 41 | + string kind = 2; |
| 42 | + } |
41 | 43 |
|
42 | | -message FaultToleranceRule { |
43 | 44 | repeated FaultToleranceRuleTargetRef targets = 1; |
44 | 45 | repeated FaultToleranceStrategyRef strategies = 2; |
45 | 46 | FaultToleranceActionRef action = 3; |
46 | 47 | } |
47 | 48 |
|
48 | 49 | // RateLimitStrategy |
49 | | - |
50 | 50 | message RateLimitStrategy { |
51 | | - string name= 1; |
| 51 | + enum MetricType { |
| 52 | + TYPE_UNKNOWN = 0; |
| 53 | + TYPE_REQUEST_AMOUNT = 1; |
| 54 | + } |
| 55 | + |
| 56 | + enum LimitMode { |
| 57 | + MODE_UNKNOWN = 0; |
| 58 | + MODE_LOCAL = 1; |
| 59 | + MODE_GLOBAL = 2; |
| 60 | + } |
52 | 61 |
|
53 | | - string metric_type = 2; |
54 | | - string limit_mode = 3; |
55 | | - int64 threshold = 4; |
56 | | - int32 stat_duration = 5; |
| 62 | + string name = 1; |
| 63 | + |
| 64 | + MetricType metric_type = 2; |
| 65 | + LimitMode limit_mode = 3; |
| 66 | + int64 threshold = 4 [(validate.rules).int64 = {gte: 0}]; |
| 67 | + int32 stat_duration = 5 [(validate.rules).int32 = {gt: 0}]; |
57 | 68 | io.opensergo.proto.common.v1.TimeUnit stat_duration_time_unit = 6; |
58 | 69 | } |
59 | 70 |
|
60 | | -// ConcurrencyLimitStrategy |
| 71 | +// ThrottlingStrategy |
| 72 | +message ThrottlingStrategy { |
| 73 | + string name = 1; |
| 74 | + |
| 75 | + int64 min_interval_millis_of_requests = 2; |
| 76 | + int64 queue_timeout_millis = 3; |
| 77 | +} |
61 | 78 |
|
| 79 | +// ConcurrencyLimitStrategy |
62 | 80 | message ConcurrencyLimitStrategy { |
63 | | - string limit_mode = 1; |
64 | | - int64 max_concurrency = 2; |
| 81 | + enum LimitMode { |
| 82 | + MODE_UNKNOWN = 0; |
| 83 | + MODE_LOCAL = 1; |
| 84 | + MODE_GLOBAL = 2; |
| 85 | + } |
| 86 | + |
| 87 | + string name = 1; |
| 88 | + |
| 89 | + LimitMode limit_mode = 2; |
| 90 | + int64 max_concurrency = 3; |
65 | 91 | } |
66 | 92 |
|
67 | 93 | // CircuitBreakerStrategy |
| 94 | +message CircuitBreakerStrategy { |
| 95 | + enum Strategy { |
| 96 | + STRATEGY_UNKNOWN = 0; |
| 97 | + STRATEGY_SLOW_REQUEST_RATIO = 1; |
| 98 | + STRATEGY_ERROR_REQUEST_RATIO = 2; |
| 99 | + } |
68 | 100 |
|
69 | | -message CircuitBreakerSlowCondition { |
70 | | - int32 max_allowed_rt_millis = 1; |
71 | | -} |
| 101 | + message CircuitBreakerSlowCondition { |
| 102 | + int32 max_allowed_rt_millis = 1; |
| 103 | + } |
72 | 104 |
|
73 | | -message CircuitBreakerErrorCondition { |
| 105 | + message CircuitBreakerErrorCondition { |
74 | 106 |
|
75 | | -} |
| 107 | + } |
76 | 108 |
|
77 | | -message CircuitBreakerStrategy { |
78 | | - string strategy = 1; |
79 | | - string trigger_ratio = 2; |
80 | | - int64 stat_duration = 3; |
81 | | - io.opensergo.proto.common.v1.TimeUnit stat_duration_time_unit = 4; |
| 109 | + string name = 1 [(validate.rules).string = {max_bytes: 1024}]; |
| 110 | + |
| 111 | + Strategy strategy = 2; |
| 112 | + double trigger_ratio = 3 [(validate.rules).double = {gte: 0.0, lte: 1.0}]; |
| 113 | + int64 stat_duration = 4 [(validate.rules).int64 = {gt: 0}]; |
| 114 | + io.opensergo.proto.common.v1.TimeUnit stat_duration_time_unit = 5; |
82 | 115 |
|
83 | | - int32 recovery_timeout = 5; |
84 | | - io.opensergo.proto.common.v1.TimeUnit recovery_timeout_time_unit = 6; |
85 | | - int32 min_request_amount = 7; |
| 116 | + int32 recovery_timeout = 6 [(validate.rules).int32 = {gt: 0}]; |
| 117 | + io.opensergo.proto.common.v1.TimeUnit recovery_timeout_time_unit = 7; |
| 118 | + int32 min_request_amount = 8 [(validate.rules).int32 = {gt: 0}]; |
86 | 119 |
|
87 | | - CircuitBreakerSlowCondition slow_condition = 8; |
88 | | - CircuitBreakerErrorCondition error_condition = 9; |
| 120 | + CircuitBreakerSlowCondition slow_condition = 9; |
| 121 | + CircuitBreakerErrorCondition error_condition = 10; |
89 | 122 | } |
| 123 | + |
0 commit comments