集群增加自动同步时钟选项

This commit is contained in:
刘祥超
2022-09-15 15:56:50 +08:00
parent c8057457cc
commit 320d381bd9
5 changed files with 79 additions and 35 deletions

View File

@@ -187,7 +187,7 @@ func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string
}
// UpdateCluster 修改集群
func (this *NodeClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name string, grantId int64, installDir string, timezone string, nodeMaxThreads int32, autoOpenPorts bool) error {
func (this *NodeClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name string, grantId int64, installDir string, timezone string, nodeMaxThreads int32, autoOpenPorts bool, clockConfig *nodeconfigs.ClockConfig) error {
if clusterId <= 0 {
return errors.New("invalid clusterId")
}
@@ -204,6 +204,14 @@ func (this *NodeClusterDAO) UpdateCluster(tx *dbs.Tx, clusterId int64, name stri
op.NodeMaxThreads = nodeMaxThreads
op.AutoOpenPorts = autoOpenPorts
if clockConfig != nil {
clockJSON, err := json.Marshal(clockConfig)
if err != nil {
return err
}
op.Clock = clockJSON
}
err := this.Save(tx, op)
if err != nil {
return err
@@ -926,7 +934,7 @@ func (this *NodeClusterDAO) FindClusterBasicInfo(tx *dbs.Tx, clusterId int64, ca
cluster, err := this.Query(tx).
Pk(clusterId).
State(NodeClusterStateEnabled).
Result("id", "timeZone", "nodeMaxThreads", "cachePolicyId", "httpFirewallPolicyId", "autoOpenPorts", "webp", "uam", "isOn", "ddosProtection").
Result("id", "timeZone", "nodeMaxThreads", "cachePolicyId", "httpFirewallPolicyId", "autoOpenPorts", "webp", "uam", "isOn", "ddosProtection", "clock").
Find()
if err != nil || cluster == nil {
return nil, err