pub struct NativeBackendBuilder<'a> { /* private fields */ }Expand description
Builder for creating a NativeBackend
Provides a fluent interface for configuring and creating native Varnish backends.
Implementations§
Source§impl<'a> NativeBackendBuilder<'a>
impl<'a> NativeBackendBuilder<'a>
Sourcepub fn new_ip(vcl_name: &'a CStr, addr: SocketAddr) -> Self
pub fn new_ip(vcl_name: &'a CStr, addr: SocketAddr) -> Self
Create a new builder for a TCP/IP backend
Sourcepub fn new_uds(vcl_name: &'a CStr, path: &'a CStr) -> Self
pub fn new_uds(vcl_name: &'a CStr, path: &'a CStr) -> Self
Create a new builder for a Unix domain socket backend
Set the authority for this backend when connecting with the PROXY
protocol
Sourcepub fn connect_timeout(self, connect_timeout: Duration) -> Self
pub fn connect_timeout(self, connect_timeout: Duration) -> Self
Set the connection timeout to the backend. Negative will count as 0s. Native backends pool their connections, meaning that connecting may not be necessary for all request.
Sourcepub fn first_byte_timeout(self, first_byte_timeout: Duration) -> Self
pub fn first_byte_timeout(self, first_byte_timeout: Duration) -> Self
Set the timeout for the first byte of the backend response.
Sourcepub fn between_bytes_timeout(self, between_bytes_timeout: Duration) -> Self
pub fn between_bytes_timeout(self, between_bytes_timeout: Duration) -> Self
Set the timeout for receving each bytes. In pratice, it’s like more of a “between TCP packet”.
Sourcepub fn max_connections(self, max_connections: u32) -> Self
pub fn max_connections(self, max_connections: u32) -> Self
Set the number of connections to pool. If a new connection needs to be
created while already at the limit, the request will be queued. See
also backend_wait_limit and backend_wait_timeout.
Sourcepub fn backend_wait_limit(self, backend_wait_limit: u32) -> Self
pub fn backend_wait_limit(self, backend_wait_limit: u32) -> Self
Set how many requests can be queue while waiting for a connection. If
the queue is full, new request will go directly to vcl_backend_error.
Sourcepub fn backend_wait_timeout(self, backend_wait_timeout: Duration) -> Self
pub fn backend_wait_timeout(self, backend_wait_timeout: Duration) -> Self
Set the time a request can wait for a connection if max_connections
is at its maximum.
Sourcepub fn hosthdr(self, hosthdr: &'a CStr) -> Self
pub fn hosthdr(self, hosthdr: &'a CStr) -> Self
Set the Host header to use sending a request that doesn’t have a
Host header.
Sourcepub fn tls(self, verify_host: bool, verify_peer: bool) -> Self
pub fn tls(self, verify_host: bool, verify_peer: bool) -> Self
Use TLS for the backend connection.
Sourcepub unsafe fn build_with_vcl(
self,
vcl: *mut vcl,
) -> VclResult<Backend<NativeVclBackendShim, NativeVclResponseShim>>
pub unsafe fn build_with_vcl( self, vcl: *mut vcl, ) -> VclResult<Backend<NativeVclBackendShim, NativeVclResponseShim>>
Build the native backend with a VCL. This can be used in cases where there’s no Ctx, like in a background thread.
§Safety
The caller must ensure that vcl is valid for the duration of this call.
Internally a minimal vrt_ctx is stack-allocated with only vcl set and passed to
VRT_new_backend. This is safe because VRT_new_backend only reads ctx during its
synchronous execution and does not retain the pointer afterward.
We use ffi::vcl here as VCL_VCL isn’t Send, and the function is unsafe anyway.
Sourcepub fn build(
self,
ctx: &mut Ctx<'_>,
) -> VclResult<Backend<NativeVclBackendShim, NativeVclResponseShim>>
pub fn build( self, ctx: &mut Ctx<'_>, ) -> VclResult<Backend<NativeVclBackendShim, NativeVclResponseShim>>
Build the native backend