Skip to content

Commit

Permalink
fix:修复熔断规则编辑后创建时间被重置 (#1091)
Browse files Browse the repository at this point in the history
  • Loading branch information
chuntaojun authored Apr 15, 2023
1 parent f292126 commit 1158ee2
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions store/boltdb/circuitbreaker_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,24 @@ func (c *circuitBreakerStore) CreateCircuitBreakerRule(cbRule *model.CircuitBrea
// UpdateCircuitBreakerRule update general circuitbreaker rule
func (c *circuitBreakerStore) UpdateCircuitBreakerRule(cbRule *model.CircuitBreakerRule) error {
dbOp := c.handler
cbRule.Valid = true
cbRule.ModifyTime = time.Now()

if err := dbOp.SaveValue(tblCircuitBreakerRule, cbRule.ID, cbRule); err != nil {
properties := map[string]interface{}{
CommonFieldName: cbRule.Name,
CommonFieldNamespace: cbRule.Namespace,
CommonFieldRevision: cbRule.Revision,
CommonFieldDescription: cbRule.Description,
CommonFieldModifyTime: time.Now(),
CbFieldLevel: cbRule.Level,
CbFieldSrcService: cbRule.SrcService,
CbFieldSrcNamespace: cbRule.SrcNamespace,
CbFieldDstService: cbRule.DstService,
CbFieldDstNamespace: cbRule.DstNamespace,
CbFieldDstMethod: cbRule.DstMethod,
CbFieldRule: cbRule.Rule,
}
if err := dbOp.UpdateValue(tblCircuitBreakerRule, cbRule.ID, properties); err != nil {
log.Errorf("[Store][CircuitBreaker] update rule(%s) exec err: %s", cbRule.ID, err.Error())
return store.Error(err)
}

return nil
}

Expand Down Expand Up @@ -176,6 +186,7 @@ const (
CbFieldDstService = "DstService"
CbFieldDstNamespace = "DstNamespace"
CbFieldDstMethod = "DstMethod"
CbFieldRule = "Rule"
)

var (
Expand Down

0 comments on commit 1158ee2

Please sign in to comment.