go proxy.healthChecker.PerformApplicationHealthCheck(func(healthEvent *health.ProbeEvent) { // Store the same response as Delta and SotW. Depending on how Envoy connects we will use one or the other. // 这里根据 PerformApplicationHealthCheck 执行的结果,创建不同的 DiscoveryRequest 分别对应 健康状态下 与 非健康状态 var req *discovery.DiscoveryRequest if healthEvent.Healthy { req = &discovery.DiscoveryRequest{TypeUrl: v3.HealthInfoType} } else { req = &discovery.DiscoveryRequest{ TypeUrl: v3.HealthInfoType, ErrorDetail: &google_rpc.Status{ Code: int32(codes.Internal), Message: healthEvent.UnhealthyMessage, }, } } proxy.PersistRequest(req) // skip DeltaDiscoveryRequest }, proxy.stopChan)
func(s *ServiceEntryStore) workloadEntryHandler(old, curr config.Config, event model.Event) { // If an entry is unhealthy, we will mark this as a delete instead // This ensures we do not track unhealthy endpoints if features.WorkloadEntryHealthChecks && !isHealthy(curr) { event = model.EventDelete }