robotLJW commented on a change in pull request #943:
URL:
https://github.com/apache/servicecomb-service-center/pull/943#discussion_r613785783
##########
File path: datasource/mongo/heartbeat/cache/heartbeatcache.go
##########
@@ -44,20 +44,25 @@ func init() {
}
type HeartBeatCache struct {
+ cfg *cacheConfig
}
func NewHeartBeatCache(opts heartbeat.Options) (heartbeat.HealthCheck, error) {
- return &HeartBeatCache{}, nil
+ return &HeartBeatCache{cfg: configuration()}, nil
}
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)
+ if ins, ok := h.cfg.instanceHeartbeatStore.Get(request.InstanceId); ok {
+ return h.inCacheStrategy(ctx, request, ins)
}
- return notInCacheStrategy(ctx, request)
+ return h.notInCacheStrategy(ctx, request)
}
-func inCacheStrategy(ctx context.Context, request *pb.HeartbeatRequest,
insHeartbeatInfo interface{}) (*pb.HeartbeatResponse, error) {
+func (h *HeartBeatCache) CheckTask(instance *pb.MicroServiceInstance) error {
+ return h.cfg.AddHeartbeatTask(instance.ServiceId, instance.InstanceId,
instance.HealthCheck.Interval*(instance.HealthCheck.Times+1))
Review comment:
已经加了注释
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]