health_check.go ×7

Frontier kind: Code frontier

unlabeled · c_ae65b7795c49

16 tests · 2920 LOC · 148 files · introduces 0 tests · 52 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges52 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
417 ranges2920 lines · 148 files · Browse complete extent
All tests (intent)
16 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 52 introduced LOC across 9 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/frontend/health_check.go 44 introduced LOC · 7 ranges

Open complete file

85 }
86
87 > receiveCh := make(chan hostResult, len(hosts)) health_check.go
88 > for _, host := range hosts {
89 > go func(hostAddress string) {
90 > resp, err := h.checkHost(ctx, hostAddress)
91 > if err != nil {
92 resp = &historyservice.DeepHealthCheckResponse{
93 State: enumsspb.HEALTH_STATE_NOT_SERVING,
101 }
102 }
103 > receiveCh <- hostResult{address: hostAddress, response: resp} health_check.go
104 }(host.GetAddress())
105 }
106
107 > var failedHostCount float64 health_check.go
108 > var hostDeclinedServingCount float64
109 > var hostDetails []*healthspb.HostHealthDetail
110 > var exampleFailedHost *healthspb.HostHealthDetail
111 > for range hosts {
112 > result := <-receiveCh
113 > state := result.response.GetState()
114 >
115 > detail := &healthspb.HostHealthDetail{
116 > Address: result.address,
117 > State: state,
118 > Checks: result.response.GetChecks(),
119 > }
120 > hostDetails = append(hostDetails, detail)
121 >
122 > switch state {
123 case enumsspb.HEALTH_STATE_SERVING:
124 // Do nothing.
133 }
134 }
135 > close(receiveCh) health_check.go
136 >
137 > // Make sure that at lease 2 hosts must be not ready to trigger this check.
138 > proportionOfDeclinedServiceHosts := ensureMinimumProportionOfHosts(h.hostDeclinedServingProportion(), len(hosts))
139 >
140 > var overallState enumsspb.HealthState
141 > hostDeclinedServingProportion := hostDeclinedServingCount / float64(len(hosts))
142 > if hostDeclinedServingProportion > proportionOfDeclinedServiceHosts {
143 h.logger.Warn("health check exceeded host declined serving proportion threshold", tag.Float64("host declined serving proportion threshold", proportionOfDeclinedServiceHosts))
144 overallState = enumsspb.HEALTH_STATE_DECLINED_SERVING
145 > } else { health_check.go
146 failedHostCountProportion := failedHostCount / float64(len(hosts))
147 if failedHostCountProportion+hostDeclinedServingProportion > h.hostFailurePercentage() {
158 }
159
160 > return HealthCheckResult{ health_check.go
161 > State: overallState,
162 > ServiceDetail: &healthspb.ServiceHealthDetail{
163 > Service: string(h.serviceName),
164 > State: overallState,
165 > Hosts: hostDetails,
166 > },
167 > }, nil
168 }
169
170 > func (h *healthCheckerImpl) checkHost(ctx context.Context, hostAddress string) (resp *historyservice.DeepHealthCheckResponse, retErr error) { health_check.go
171 > defer log.CapturePanic(h.logger, &retErr)
172 >
173 > resp, err := h.healthCheckFn(ctx, hostAddress)
174 > if err != nil {
175 h.logger.Warn("failed to ping deep health check", tag.Error(err), tag.ServerName(string(h.serviceName)))
176 return nil, err
go.temporal.io/server/api/historyservice/v1/request_response.pb.go 8 introduced LOC · 2 ranges

Open complete file

9296 }
9297
9298 > func (x *DeepHealthCheckResponse) GetState() v112.HealthState { request_response.pb.go
9299 > if x != nil {
9300 > return x.State
9301 > }
9302 return v112.HealthState(0)
9303 }
9304
9305 > func (x *DeepHealthCheckResponse) GetChecks() []*v122.HealthCheck { request_response.pb.go
9306 > if x != nil {
9307 > return x.Checks
9308 > }
9309 return nil
9310 }