execute invokes the given healthcheck checker with the configured timeout.
()
| 358 | |
| 359 | // execute invokes the given healthcheck checker with the configured timeout. |
| 360 | func (hc *Check) execute() *Result { |
| 361 | ch := make(chan *Result, 1) |
| 362 | checker := hc.Checker |
| 363 | timeout := hc.Timeout |
| 364 | go func() { |
| 365 | // TODO(jsing): Determine a way to ensure that this go routine |
| 366 | // does not linger. |
| 367 | ch <- checker.Check(timeout) |
| 368 | }() |
| 369 | select { |
| 370 | case result := <-ch: |
| 371 | return result |
| 372 | case <-time.After(timeout): |
| 373 | return &Result{"Timed out", false, timeout, nil} |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | // Stop notifies a running healthcheck that it should quit. |
| 378 | func (hc *Check) Stop() { |