Skip to content

Commit

Permalink
Add flow control policy sample
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzhiguo committed Jan 7, 2025
1 parent 8152749 commit cce491e
Showing 1 changed file with 333 additions and 0 deletions.
333 changes: 333 additions & 0 deletions joylive-package/src/main/assembly/config/microservice.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,45 @@
"token.key": "Authorization"
}
},
"faultInjectionPolicies": [
{
"name": "fault-rule-1",
"version": 1704038400000,
"type": "delay",
"percent": 50,
"delayTimeMs": 1000,
"relationType": "AND",
"conditions": [
{
"type": "query",
"opType": "EQUAL",
"key": "fault",
"values": [
"true"
]
}
]
},
{
"name": "fault-rule-2",
"version": 1704038400000,
"type": "error",
"percent": 50,
"errorCode": 400,
"errorMsg": "Fault Injection Error",
"relationType": "AND",
"conditions": [
{
"type": "query",
"opType": "EQUAL",
"key": "fault",
"values": [
"true"
]
}
]
}
],
"rateLimitPolicies": [
{
"name": "limit-rule-1",
Expand Down Expand Up @@ -714,5 +753,299 @@
]
}
]
},
{
"name": "grpc-consumer",
"serviceType": "RPC_APP",
"version": 0,
"groups": [
{
"name": "default",
"defaultGroup": true,
"servicePolicy": {
"livePolicy": {
"unitPolicy": "UNIT"
},
"loadBalancePolicy": {
"policyType": "ROUND_ROBIN"
},
"rateLimitPolicies": [
{
"name": "limit-rule-1",
"version": 1704038400000,
"realizeType": "Resilience4j",
"slidingWindows": [
{
"threshold": 1,
"timeWindowInMs": 1000
}
],
"maxWaitMs": 100,
"actionParameters": {
},
"relationType": "AND",
"conditions": [
{
"type": "header",
"opType": "EQUAL",
"key": "limiter",
"values": [
"true"
]
}
]
}
]
},
"paths": [
{
"path": "/get",
"matchType": "EQUAL",
"servicePolicy": {
"livePolicy": {
"writeProtect": false,
"cellPolicy": "PREFER_LOCAL_CELL"
}
},
"methods": [
{
"name": "GET",
"servicePolicy": {
"livePolicy": {
"cellPolicy": "PREFER_LOCAL_CELL",
"cellRemotes": [
{
"name": "cell1",
"type": "INSTANCES",
"threshold": 3
}
]
}
}
}
]
}
]
}
]
},
{
"name": "grpc-provider",
"serviceType": "RPC_APP",
"version": 0,
"groups": [
{
"name": "default",
"defaultGroup": true,
"servicePolicy": {
"livePolicy": {
"unitPolicy": "PREFER_LOCAL_UNIT"
},
"loadBalancePolicy": {
"policyType": "ROUND_ROBIN"
},
"clusterPolicy": {
"type": "failover",
"retryPolicy": {
"retry": 10,
"interval": 1000,
"timeout": 5000,
"errorCodes": [
500,
502
],
"methods": [
"GET"
],
"exceptions": [
"java.lang.NullPointException"
],
"version": 1704038400000
}
},
"rateLimitPolicies": [
{
"name": "limit-rule-1",
"version": 1704038400000,
"realizeType": "Resilience4j",
"slidingWindows": [
{
"threshold": 1,
"timeWindowInMs": 1000
},
{
"threshold": 3,
"timeWindowInMs": 2000
}
],
"maxWaitMs": 100,
"actionParameters": {
},
"relationType": "AND",
"conditions": [
{
"type": "header",
"opType": "EQUAL",
"key": "limiter",
"values": [
"true"
]
}
]
}
],
"concurrencyLimitPolicies": [
{
"name": "limit-rule-2",
"version": 1704038400000,
"realizeType": "Resilience4j",
"maxConcurrency": 10,
"maxWaitMs": 100,
"actionParameters": {
},
"relationType": "AND",
"conditions": [
{
"type": "header",
"opType": "EQUAL",
"key": "limiter",
"values": [
"true"
]
}
]
}
],
"permissionPolicies": [
{
"name": "auth-rule-2",
"version": 1704038400001,
"relationType": "AND",
"conditions": [
{
"type": "header",
"opType": "EQUAL",
"key": "x-live-unit",
"values": [
"unit1"
]
}
],
"type": "DENY"
}
],
"routePolicies": [
{
"name": "route1",
"order": 10,
"tagRules": [
{
"order": 10,
"relationType": "AND",
"conditions": [
{
"opType": "EQUAL",
"type": "header",
"key": "x-live-unit",
"values": [
"unit1"
]
}
],
"destinations": [
{
"weight": 100,
"relationType": "AND",
"conditions": [
{
"opType": "EQUAL",
"key": "x-live-unit",
"values": [
"unit1"
]
}
]
}
]
}
]
},
{
"name": "route2",
"order": 10,
"tagRules": [
{
"order": 10,
"relationType": "OR",
"conditions": [
{
"opType": "EQUAL",
"type": "header",
"key": "x-live-unit",
"values": [
"unit2"
]
},
{
"opType": "IN",
"type": "header",
"key": "x-live-cell",
"values": [
"cell3"
]
}
],
"destinations": [
{
"weight": 100,
"relationType": "AND",
"conditions": [
{
"opType": "EQUAL",
"key": "x-live-unit",
"values": [
"unit2"
]
}
]
}
]
}
]
}
],
"circuitBreakPolicies": [
{
"name": "cb1",
"level": "SERVICE",
"slidingWindowType": "time",
"slidingWindowSize": 5,
"minCallsThreshold": 1,
"errorCodes": [
"500",
"502"
],
"failureRateThreshold": 20,
"slowCallRateThreshold": 20,
"slowCallDurationThreshold": 1000,
"waitDurationInOpenState": 50,
"allowedCallsInHalfOpenState": 3,
"forceOpen": false,
"realizeType": "Resilience4j",
"degradeConfig": {
"responseCode": 200,
"attributes": {
"degrade-header-1": "service1",
"degrade-header-2": "service2"
},
"responseBody": ""
},
"version": 1
}
]
},
"paths": []
}
]
}
]

0 comments on commit cce491e

Please sign in to comment.