| 354 | } |
| 355 | |
| 356 | func (p *TCPReadinessProbe) Ready(runnable Runnable) (err error) { |
| 357 | endpoint := runnable.Endpoint(p.portName) |
| 358 | if endpoint == "" { |
| 359 | return errors.Newf("cannot get service endpoint for port %s", p.portName) |
| 360 | } else if endpoint == "stopped" { |
| 361 | return errors.New("service has stopped") |
| 362 | } |
| 363 | |
| 364 | conn, err := net.DialTimeout("tcp", endpoint, time.Second) |
| 365 | if err != nil { |
| 366 | return err |
| 367 | } |
| 368 | |
| 369 | return conn.Close() |
| 370 | } |
| 371 | |
| 372 | // CmdReadinessProbe checks readiness by `Exec`ing a command (within container) which returns 0 to consider status being ready. |
| 373 | type CmdReadinessProbe struct { |