Skip to content

Commit

Permalink
dashboard support regex match (alibaba#3305)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxiaof authored Feb 1, 2024
1 parent a524ab3 commit 6248799
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public abstract class AbstractRuleEntity<T extends AbstractRule> implements Rule

protected T rule;

/**
* Whether to match resource names according to regular rules
*/
private boolean regex = false;

private Date gmtCreate;
private Date gmtModified;

Expand Down Expand Up @@ -86,6 +91,15 @@ public AbstractRuleEntity<T> setRule(T rule) {
return this;
}

public boolean isRegex() {
return regex;
}

public AbstractRuleEntity<T> setRegex(boolean regex) {
this.regex = regex;
return this;
}

@Override
public Date getGmtCreate() {
return gmtCreate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static AuthorityRuleEntity fromAuthorityRule(String app, String ip, Integ
entity.setApp(app);
entity.setIp(ip);
entity.setPort(port);
entity.setRegex(rule.isRegex());
return entity;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public class DegradeRuleEntity implements RuleEntity {
private Integer minRequestAmount;
private Double slowRatioThreshold;
private Integer statIntervalMs;
/**
* Whether to match resource names according to regular rules
*/
private boolean regex = false;

private Date gmtCreate;
private Date gmtModified;
Expand All @@ -55,6 +59,7 @@ public static DegradeRuleEntity fromDegradeRule(String app, String ip, Integer p
entity.setMinRequestAmount(rule.getMinRequestAmount());
entity.setSlowRatioThreshold(rule.getSlowRatioThreshold());
entity.setStatIntervalMs(rule.getStatIntervalMs());
entity.setRegex(rule.isRegex());
return entity;
}

Expand Down Expand Up @@ -162,6 +167,14 @@ public DegradeRuleEntity setStatIntervalMs(Integer statIntervalMs) {
return this;
}

public boolean isRegex() {
return regex;
}

public void setRegex(boolean regex) {
this.regex = regex;
}

@Override
public Date getGmtCreate() {
return gmtCreate;
Expand Down Expand Up @@ -197,6 +210,7 @@ public DegradeRule toRule() {
rule.setStatIntervalMs(statIntervalMs);
}

rule.setRegex(regex);
return rule;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public class FlowRuleEntity implements RuleEntity {
*/
private ClusterFlowConfig clusterConfig;

/**
* Whether to match resource names according to regular rules
*/
private boolean regex = false;

private Date gmtCreate;
private Date gmtModified;

Expand All @@ -76,6 +81,7 @@ public static FlowRuleEntity fromFlowRule(String app, String ip, Integer port, F
entity.setMaxQueueingTimeMs(rule.getMaxQueueingTimeMs());
entity.setClusterMode(rule.isClusterMode());
entity.setClusterConfig(rule.getClusterConfig());
entity.setRegex(rule.isRegex());
return entity;
}

Expand Down Expand Up @@ -206,6 +212,14 @@ public FlowRuleEntity setClusterConfig(ClusterFlowConfig clusterConfig) {
return this;
}

public boolean isRegex() {
return regex;
}

public void setRegex(boolean regex) {
this.regex = regex;
}

@Override
public Date getGmtCreate() {
return gmtCreate;
Expand Down Expand Up @@ -243,6 +257,7 @@ public FlowRule toRule() {
}
flowRule.setClusterMode(clusterMode);
flowRule.setClusterConfig(clusterConfig);
flowRule.setRegex(regex);
return flowRule;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static ParamFlowRuleEntity fromParamFlowRule(String app, String ip, Integ
entity.setApp(app);
entity.setIp(ip);
entity.setPort(port);
entity.setRegex(rule.isRegex());
return entity;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
<form role="form" class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">资源名</label>
<div class="col-sm-9">
<div class="col-sm-6">
<input type="text" ng-if="authorityRuleDialog.type == 'edit'" class="form-control" placeholder="资源名" ng-model='currentRule.rule.resource'
disabled="" />
<input type="text" ng-if="authorityRuleDialog.type == 'add'" class="form-control highlight-border" placeholder="资源名称" ng-model='currentRule.rule.resource'
/>
</div>
<label class="col-sm-2 control-label">是否正则</label>
<div class="col-sm-2">
<label class="checkbox-inline">
<input type="checkbox" ng-if="authorityRuleDialog.type == 'add'" name="regex" ng-model="currentRule.rule.regex">
<input type="checkbox" ng-if="authorityRuleDialog.type == 'edit'" name="regex" ng-model="currentRule.rule.regex" disabled="">
</label>
</div>
</div>

<div class="form-group">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
<form role="form" class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">资源名</label>
<div class="col-sm-9">
<div class="col-sm-6">
<input type="text" ng-if="degradeRuleDialog.type == 'edit'" class="form-control" placeholder="资源名" ng-model='currentRule.resource'
disabled="" />
<input type="text" ng-if="degradeRuleDialog.type == 'add'" class="form-control highlight-border" placeholder="资源名" ng-model='currentRule.resource'
/>
</div>
<label class="col-sm-2 control-label">是否正则</label>
<div class="col-sm-2">
<label class="checkbox-inline">
<input type="checkbox" ng-if="degradeRuleDialog.type == 'add'" name="regex" ng-model="currentRule.regex">
<input type="checkbox" ng-if="degradeRuleDialog.type == 'edit'" name="regex" ng-model="currentRule.regex" disabled="">
</label>
</div>
</div>

<!--<div class="form-group">-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
<form role="form" class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">资源名</label>
<div class="col-sm-9">
<div class="col-sm-6">
<input type="text" ng-if="flowRuleDialog.type == 'edit'" class="form-control" placeholder="资源名" ng-model='currentRule.resource'
disabled="" />
<input type="text" ng-if="flowRuleDialog.type == 'add'" class="form-control highlight-border" placeholder="资源名" ng-model='currentRule.resource'
/>
</div>
<label class="col-sm-2 control-label">是否正则</label>
<div class="col-sm-2">
<label class="checkbox-inline">
<input type="checkbox" ng-if="flowRuleDialog.type == 'add'" name="regex" ng-model="currentRule.regex">
<input type="checkbox" ng-if="flowRuleDialog.type == 'edit'" name="regex" ng-model="currentRule.regex" disabled="">
</label>
</div>
</div>

<div class="form-group">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@
<form role="form" class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">资源名</label>
<div class="col-sm-9">
<div class="col-sm-6">
<input type="text" ng-if="paramFlowRuleDialog.type == 'edit'" class="form-control" placeholder="资源名" ng-model='currentRule.rule.resource' disabled="" />
<input type="text" ng-if="paramFlowRuleDialog.type == 'add'" class="form-control highlight-border" placeholder="资源名" ng-model='currentRule.rule.resource' required />
</div>
<label class="col-sm-2 control-label">是否正则</label>
<div class="col-sm-2">
<label class="checkbox-inline">
<input type="checkbox" ng-if="paramFlowRuleDialog.type == 'add'" name="regex" ng-model="currentRule.rule.regex">
<input type="checkbox" ng-if="paramFlowRuleDialog.type == 'edit'" name="regex" ng-model="currentRule.rule.regex" disabled="">
</label>
</div>
</div>

<div class="form-group">
Expand Down

0 comments on commit 6248799

Please sign in to comment.