pub struct TcpHealthCheck {
pub consecutive_success: usize,
pub consecutive_failure: usize,
pub peer_template: BasicPeer,
pub health_changed_callback: Option<HealthObserveCallback>,
/* private fields */
}
Expand description
TCP health check
This health check checks if a TCP (or TLS) connection can be established to a given backend.
Fields§
§consecutive_success: usize
Number of successful checks to flip from unhealthy to healthy.
consecutive_failure: usize
Number of failed checks to flip from healthy to unhealthy.
peer_template: BasicPeer
How to connect to the backend.
This field defines settings like the connect timeout and src IP to bind.
The SocketAddr of peer_template
is just a placeholder which will be replaced by the
actual address of the backend when the health check runs.
By default, this check will try to establish a TCP connection. When the sni
field is
set, it will also try to establish a TLS connection on top of the TCP connection.
health_changed_callback: Option<HealthObserveCallback>
A callback that is invoked when the healthy
status changes for a Backend.
Implementations§
Source§impl TcpHealthCheck
impl TcpHealthCheck
Sourcepub fn new() -> Box<Self>
pub fn new() -> Box<Self>
Create a new TcpHealthCheck with the following default values
- connect timeout: 1 second
- consecutive_success: 1
- consecutive_failure: 1
Sourcepub fn new_tls(sni: &str) -> Box<Self>
pub fn new_tls(sni: &str) -> Box<Self>
Create a new TcpHealthCheck that tries to establish a TLS connection.
The default values are the same as Self::new().
Sourcepub fn set_connector(&mut self, connector: TransportConnector)
pub fn set_connector(&mut self, connector: TransportConnector)
Replace the internal tcp connector with the given TransportConnector