HealthcheckBuilder

pub struct HealthcheckBuilder { /* private fields */ }

A builder structure for generating healthchecks for a dynamic backend

This structure can be constructed using either Backend::healthcheck_builder() or its own new() method, and will generate a new healthcheck for use by the DynamicBackendBuilder after consuming the BackendBuilder with finish().

Methods

expected_status

View source
fn expected_status(self, value: u16) -> Self

Sets the HTTP status code that signifies a healthy state.

Defaults to 200.

Parameters

self: Self
value: u16

Returns

Self

get_expected_status

View source
fn get_expected_status(&self) -> u16

Returns the expected_status from the HealthcheckBuilder

Parameters

self: &Self

Returns

u16

get_host

View source
fn get_host(&self) -> &str

Returns the host from the HealthcheckBuilder

Parameters

self: &Self

Returns

&str

get_initial

View source
fn get_initial(&self) -> u32

Returns the initial from the HealthcheckBuilder

Parameters

self: &Self

Returns

u32

get_interval_ms

View source
fn get_interval_ms(&self) -> Duration

Returns the interval_ms from the HealthcheckBuilder

Parameters

self: &Self

Returns

get_method

View source
fn get_method(&self) -> &str

Returns the method from the HealthcheckBuilder

Parameters

self: &Self

Returns

&str

get_path

View source
fn get_path(&self) -> &PathAndQuery

Returns the path from the HealthcheckBuilder

Parameters

self: &Self

Returns

get_threshold

View source
fn get_threshold(&self) -> u32

Returns the threshold from the HealthcheckBuilder

Parameters

self: &Self

Returns

u32

get_timeout_ms

View source
fn get_timeout_ms(&self) -> Duration

Returns the timeout_ms from the HealthcheckBuilder

Parameters

self: &Self

Returns

get_window

View source
fn get_window(&self) -> u32

Returns the window from the HealthcheckBuilder

Parameters

self: &Self

Returns

u32
fn host(self, name: impl ToString) -> Self

Set the Host header to set when making the request (e.g. example.com).

A common mistake is setting the wrong host header, which causes the health check to fail.

Parameters

self: Self
name: impl ToString

Returns

Self
fn initial(self, value: u32) -> Self

Set the number of successes to assume are successful when beginning a health check. Must not be greater than the current window.

Defaults to 4.

Parameters

self: Self
value: u32

Returns

Self

interval_ms

View source
fn interval_ms(self, value: Duration) -> Self

Set the interval in milliseconds where a health check should be performed. Times must be 1 second to 1 hour inclusive. Must be less than the current timeout_ms.

Defaults to 15000ms.

Parameters

self: Self
value: Duration

Returns

Self
fn method(self, value: impl ToString) -> Self

Set an HTTP verb (i.e., HEAD, GET, or POST) to use when performing the health check.

Defaults to "GET".

Parameters

self: Self
value: impl ToString

Returns

Self
fn new(host: impl ToString) -> Self

Create a new health check builder for a dynamic backend.

The argument is a string describing the backend host on which to check health checks on. This can be of the form:

  • "<ip address>"
  • "<hostname>"
  • "<ip address>:<port>"
  • "<hostname>:<port>"

The builder will start with default values for all other possible fields for the health check, which can be overridden using the other methods provided. Use BackendBuilder::healthcheck to add the health check to a specific Dynamic Backend and call BackendBuilder::finish() to complete the construction of the dynamic backend.

Values for health checks have strict limits to prevent ill-use. If you create a health check with a value that breaks these limits, finish() will error with a BackendCreationError:InvalidHealthcheckValues

Parameters

host: impl ToString

Returns

Self
fn path(self, value: impl ToString) -> Self

Set a path to visit on your origins when performing the check. Use a unique path. For example, use /website-healthcheck.txt, not / or /healthcheck.

Defaults to "/".

Parameters

self: Self
value: impl ToString

Returns

Self

threshold

View source
fn threshold(self, value: u32) -> Self

Set the number of health checks that must be successful within the window to be considered healthy. Must not be greater than the current window.

Defaults to 3.

Parameters

self: Self
value: u32

Returns

Self

timeout_ms

View source
fn timeout_ms(self, value: Duration) -> Self

Set the time in milliseconds in which to perform the health check. Note that querying the health check renews the timer. Must not be less than the current interval_ms.

Defaults to 5000ms.

Parameters

self: Self
value: Duration

Returns

Self

validate

View source
fn validate(&self) -> Result<(), BackendCreationError>

Validate that the current health check has acceptable values

Parameters

self: &Self

Returns

fn window(self, value: u32) -> Self

Set the number of most recent health check queries to keep. Must not be greater than 15.

Defaults to 5.

Parameters

self: Self
value: u32

Returns

Self

Trait implementations

impl Clone for HealthcheckBuilder

fn clone(&self) -> Self

Parameters

self: &Self

Returns

Self

Auto trait implementations

Blanket implementations