Skip to content

Commit

Permalink
fix: config
Browse files Browse the repository at this point in the history
  • Loading branch information
icey-yu committed Dec 25, 2024
1 parent 51fe509 commit 4963b8f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions internal/api/config_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,22 @@ func (cm *ConfigManager) resetConfig(c *gin.Context) {
}
}

ops := make([]clientv3.Op, 0)
for _, k := range changedKeys {
data, err := json.Marshal(configMap[k].new)
if err != nil {
log.ZError(c, "marshal config failed", err)
continue
}
txn = txn.Then(clientv3.OpPut(etcd.BuildKey(k), string(data)))
ops = append(ops, clientv3.OpPut(etcd.BuildKey(k), string(data)))
}
_, err := txn.Commit()
if err != nil {
log.ZError(c, "commit etcd txn failed", err)
return
if len(ops) > 0 {
txn.Then(ops...)
_, err := txn.Commit()
if err != nil {
log.ZError(c, "commit etcd txn failed", err)
return
}
}
}

Expand Down

0 comments on commit 4963b8f

Please sign in to comment.