Skip to content

Commit 6e99573

Browse files
author
songshiyuan 00649746
committed
[feat] support refresh the config of syncer without redeploy servicecomb-center
1 parent 0534041 commit 6e99573

4 files changed

Lines changed: 22 additions & 4 deletions

File tree

syncer/config/config.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ import (
2121
"fmt"
2222
"path/filepath"
2323

24+
"github.com/go-chassis/go-archaius"
25+
2426
"github.com/apache/servicecomb-service-center/pkg/log"
2527
"github.com/apache/servicecomb-service-center/pkg/util"
26-
"github.com/go-chassis/go-archaius"
2728
)
2829

2930
var config Config
@@ -45,7 +46,7 @@ type Peer struct {
4546
}
4647

4748
func Init() error {
48-
err := archaius.AddFile(filepath.Join(util.GetAppRoot(), "conf", "syncer.yaml"))
49+
err := archaius.AddFile(filepath.Join(util.GetAppRoot(), "conf", "syncer", "syncer.yaml"))
4950
if err != nil {
5051
log.Warn(fmt.Sprintf("can not add syncer config file source, error: %s", err))
5152
return err

syncer/service/admin/health.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ func getPeerStatus(peerName string, clientConn *grpc.ClientConn) string {
127127
reply, err := set.EventServiceClient.Health(context.Background(), &v1sync.HealthRequest{})
128128
if err != nil || reply == nil {
129129
log.Error("get peer health failed", err)
130+
err1 := config.Reload()
131+
if err1 != nil {
132+
log.Error("reload syncer config fail", err1)
133+
return rpc.HealthStatusAbnormal
134+
}
135+
Init()
130136
return rpc.HealthStatusAbnormal
131137
}
132138
reportClockDiff(peerName, local, reply.LocalTimestamp)

syncer/service/replicator/replicator.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import (
2121
"context"
2222
"fmt"
2323

24+
"github.com/go-chassis/foundation/gopool"
25+
"google.golang.org/grpc"
26+
2427
"github.com/apache/servicecomb-service-center/client"
2528
"github.com/apache/servicecomb-service-center/pkg/log"
2629
"github.com/apache/servicecomb-service-center/pkg/rpc"
@@ -29,8 +32,6 @@ import (
2932
syncerclient "github.com/apache/servicecomb-service-center/syncer/client"
3033
"github.com/apache/servicecomb-service-center/syncer/config"
3134
"github.com/apache/servicecomb-service-center/syncer/service/replicator/resource"
32-
"github.com/go-chassis/foundation/gopool"
33-
"google.golang.org/grpc"
3435
)
3536

3637
const (
@@ -165,6 +166,16 @@ func (r *replicatorManager) replicate(ctx context.Context, el *v1sync.EventList)
165166
for _, in := range els {
166167
res, err := set.EventServiceClient.Sync(ctx, in)
167168
if err != nil {
169+
err1 := config.Reload()
170+
if err1 != nil {
171+
log.Error("reload syncer config fail", err1)
172+
return nil, err
173+
}
174+
err2 := InitSyncClient()
175+
if err2 != nil {
176+
log.Error("reInit syncClient fail", err2)
177+
return nil, err
178+
}
168179
return nil, err
169180
}
170181

0 commit comments

Comments
 (0)