Skip to content

Commit dab8312

Browse files
committed
Batch find api supports null instance protection
1 parent 47b2e16 commit dab8312

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

pkg/protect/protect.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import (
66
"net/http"
77
"time"
88

9+
"github.com/apache/servicecomb-service-center/server/health"
910
"github.com/go-chassis/foundation/gopool"
1011

1112
"github.com/apache/servicecomb-service-center/pkg/log"
1213
"github.com/apache/servicecomb-service-center/server/config"
13-
"github.com/apache/servicecomb-service-center/server/service/registry"
1414
)
1515

1616
/**
@@ -65,7 +65,7 @@ func watch(ctx context.Context) {
6565
case <-ctx.Done():
6666
return
6767
case <-time.After(defaultReadinessCheckInterval):
68-
err := registry.Readiness(ctx)
68+
err := health.GlobalReadinessChecker().Healthy()
6969
if err != nil {
7070
AlwaysProtection()
7171
continue

server/service/disco/instance.go

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"sync"
2626
"time"
2727

28+
"github.com/apache/servicecomb-service-center/pkg/protect"
2829
pb "github.com/go-chassis/cari/discovery"
2930
"github.com/go-chassis/cari/pkg/errsvc"
3031

@@ -384,12 +385,18 @@ func AppendFindResponse(ctx context.Context, index int64, resp *pb.Response, ins
384385
(*failedResult).Indexes = append((*failedResult).Indexes, index)
385386
return
386387
}
388+
389+
if len(instances) == 0 && protect.ShouldProtectOnNullInstance() {
390+
*notModifiedResult = append(*notModifiedResult, index)
391+
return
392+
}
387393
iv, _ := ctx.Value(util.CtxRequestRevision).(string)
388394
ov, _ := ctx.Value(util.CtxResponseRevision).(string)
389395
if len(iv) > 0 && iv == ov {
390396
*notModifiedResult = append(*notModifiedResult, index)
391397
return
392398
}
399+
393400
*updatedResult = append(*updatedResult, &pb.FindResult{
394401
Index: index,
395402
Instances: instances,

0 commit comments

Comments
 (0)