Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import com.alibaba.csp.sentinel.dashboard.auth.AuthAction;
import com.alibaba.csp.sentinel.dashboard.auth.AuthService.PrivilegeType;
import com.alibaba.csp.sentinel.slots.block.flow.ClusterFlowConfig;
import com.alibaba.csp.sentinel.util.StringUtil;

import com.alibaba.csp.sentinel.dashboard.client.SentinelApiClient;
Expand Down Expand Up @@ -164,7 +165,8 @@ public Result<FlowRuleEntity> apiUpdateFlowRule(Long id, String app,
String limitApp, String resource, Integer grade,
Double count, Integer strategy, String refResource,
Integer controlBehavior, Integer warmUpPeriodSec,
Integer maxQueueingTimeMs) {
Integer maxQueueingTimeMs, Boolean clusterMode,
Integer thresholdType, Boolean fallbackToLocalWhenFail) {
if (id == null) {
return Result.ofFail(-1, "id can't be null");
}
Expand Down Expand Up @@ -222,6 +224,19 @@ public Result<FlowRuleEntity> apiUpdateFlowRule(Long id, String app,
}
Date date = new Date();
entity.setGmtModified(date);
if (clusterMode != null) {
entity.setClusterMode(clusterMode);
}
if (clusterMode) {
ClusterFlowConfig clusterFlowConfig = new ClusterFlowConfig();
if (thresholdType != null) {
clusterFlowConfig.setThresholdType(thresholdType);
}
if (fallbackToLocalWhenFail != null) {
clusterFlowConfig.setFallbackToLocalWhenFail(fallbackToLocalWhenFail);
}
entity.setClusterConfig(clusterFlowConfig);
}
try {
entity = repository.save(entity);
if (entity == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ app.controller('FlowControllerV1', ['$scope', '$stateParams', 'FlowServiceV1', '
limitApp: 'default',
clusterMode: false,
clusterConfig: {
thresholdType: 0
thresholdType: 0,
fallbackToLocalWhenFail : true
}
};
$scope.flowRuleDialog = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ app.service('FlowServiceV1', ['$http', function ($http) {
controlBehavior: rule.controlBehavior,
warmUpPeriodSec: rule.warmUpPeriodSec,
maxQueueingTimeMs: rule.maxQueueingTimeMs,
clusterMode: rule.clusterMode,
thresholdType: rule.clusterMode ? rule.clusterConfig.thresholdType : undefined,
fallbackToLocalWhenFail: rule.clusterMode ? rule.clusterConfig.fallbackToLocalWhenFail :undefined
};

return $http({
Expand Down Expand Up @@ -110,7 +113,7 @@ app.service('FlowServiceV1', ['$http', function ($http) {
alert('排队超时时间必须大于 0');
return false;
}
if (rule.clusterMode && (rule.clusterConfig === undefined || rule.clusterConfig.thresholdType === undefined)) {
if (rule.clusterMode && (rule.clusterConfig === undefined || null === rule.clusterConfig || rule.clusterConfig.thresholdType === undefined)) {
alert('集群限流配置不正确');
return false;
}
Expand Down
Loading