You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2021/04/13 08:52:27 UTC
[servicecomb-service-center] branch master updated: SCB-2094 fix:
Nonstandard naming Heartbeatcheck (#941)
This is an automated email from the ASF dual-hosted git repository.
littlecui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git
The following commit(s) were added to refs/heads/master by this push:
new 1b42ef3 SCB-2094 fix: Nonstandard naming Heartbeatcheck (#941)
1b42ef3 is described below
commit 1b42ef35c2874a4ef78d0612e05bb5358fae3410
Author: luojianwen <79...@qq.com>
AuthorDate: Tue Apr 13 16:52:19 2021 +0800
SCB-2094 fix: Nonstandard naming Heartbeatcheck (#941)
---
datasource/mongo/heartbeat/cache/heartbeatcache.go | 10 +++++-----
datasource/mongo/heartbeat/cache/heartbeatcache_test.go | 6 +++---
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/datasource/mongo/heartbeat/cache/heartbeatcache.go b/datasource/mongo/heartbeat/cache/heartbeatcache.go
index e3d229f..31ae699 100644
--- a/datasource/mongo/heartbeat/cache/heartbeatcache.go
+++ b/datasource/mongo/heartbeat/cache/heartbeatcache.go
@@ -40,17 +40,17 @@ const (
var ErrHeartbeatConversionFailed = errors.New("instanceHeartbeatInfo type conversion failed. ")
func init() {
- heartbeat.Install("cache", NewHeartBeatCheck)
+ heartbeat.Install("cache", NewHeartBeatCache)
}
-type HeartBeatCheck struct {
+type HeartBeatCache struct {
}
-func NewHeartBeatCheck(opts heartbeat.Options) (heartbeat.HealthCheck, error) {
- return &HeartBeatCheck{}, nil
+func NewHeartBeatCache(opts heartbeat.Options) (heartbeat.HealthCheck, error) {
+ return &HeartBeatCache{}, nil
}
-func (h *HeartBeatCheck) Heartbeat(ctx context.Context, request *pb.HeartbeatRequest) (*pb.HeartbeatResponse, error) {
+func (h *HeartBeatCache) Heartbeat(ctx context.Context, request *pb.HeartbeatRequest) (*pb.HeartbeatResponse, error) {
if ins, ok := instanceHeartbeatStore.Get(request.InstanceId); ok {
return inCacheStrategy(ctx, request, ins)
}
diff --git a/datasource/mongo/heartbeat/cache/heartbeatcache_test.go b/datasource/mongo/heartbeat/cache/heartbeatcache_test.go
index 028eb66..da2308a 100644
--- a/datasource/mongo/heartbeat/cache/heartbeatcache_test.go
+++ b/datasource/mongo/heartbeat/cache/heartbeatcache_test.go
@@ -33,7 +33,7 @@ import (
func TestHeartBeatCheck(t *testing.T) {
t.Run("heartbeat check: instance does not exist,it should be failed", func(t *testing.T) {
- heartBeatCheck := &HeartBeatCheck{}
+ heartBeatCheck := &HeartBeatCache{}
resp, err := heartBeatCheck.Heartbeat(context.Background(), &pb.HeartbeatRequest{
ServiceId: "serviceId1",
InstanceId: "not-exist-ins",
@@ -45,7 +45,7 @@ func TestHeartBeatCheck(t *testing.T) {
t.Run("heartbeat check: data exists in the cache,but not in db,it should be failed", func(t *testing.T) {
err := addHeartbeatTask("not-exist-svc", "not-exist-ins", 30)
assert.Nil(t, err)
- heartBeatCheck := &HeartBeatCheck{}
+ heartBeatCheck := &HeartBeatCache{}
resp, err := heartBeatCheck.Heartbeat(context.Background(), &pb.HeartbeatRequest{
ServiceId: "serviceId1",
InstanceId: "not-exist-ins",
@@ -55,7 +55,7 @@ func TestHeartBeatCheck(t *testing.T) {
})
t.Run("heartbeat check: data exists in the cache and db,it can be update successfully", func(t *testing.T) {
- heartBeatCheck := &HeartBeatCheck{}
+ heartBeatCheck := &HeartBeatCache{}
instanceDB := model.Instance{
RefreshTime: time.Now(),
Instance: &pb.MicroServiceInstance{