Class SocketHealthCheck

  • All Implemented Interfaces:
    org.eclipse.microprofile.health.HealthCheck

    public class SocketHealthCheck
    extends Object
    implements org.eclipse.microprofile.health.HealthCheck
    Health check implementation to check if host is reachable using a socket.
     
     @Produces
     @ApplicationScoped
     @Liveness
     HealthCheck check1() {
         return new SocketHealthCheck("192.168.0.2", 5432);
     }
     
     
    See Also:
    Socket
    • Constructor Detail

      • SocketHealthCheck

        public SocketHealthCheck​(String host,
                                 int port)
    • Method Detail

      • call

        public org.eclipse.microprofile.health.HealthCheckResponse call()
        Specified by:
        call in interface org.eclipse.microprofile.health.HealthCheck
      • name

        public SocketHealthCheck name​(String name)
        Sets the name of the health check.
        Parameters:
        name - of health check.
        Returns:
        SocketHealthCheck instance.
      • timeout

        public SocketHealthCheck timeout​(int timeout)
        Sets timeout in millis.
        Parameters:
        timeout - in millis.
        Returns:
        SocketHealthCheck instance.