Skip to main content

NativeBackendBuilder

Struct NativeBackendBuilder 

Source
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>

Source

pub fn new_ip(vcl_name: &'a CStr, addr: SocketAddr) -> Self

Create a new builder for a TCP/IP backend

Source

pub fn new_uds(vcl_name: &'a CStr, path: &'a CStr) -> Self

Create a new builder for a Unix domain socket backend

Source

pub fn authority(self, authority: &'a CStr) -> Self

Set the authority for this backend when connecting with the PROXY protocol

Source

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.

Source

pub fn first_byte_timeout(self, first_byte_timeout: Duration) -> Self

Set the timeout for the first byte of the backend response.

Source

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”.

Source

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.

Source

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.

Source

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.

Source

pub fn hosthdr(self, hosthdr: &'a CStr) -> Self

Set the Host header to use sending a request that doesn’t have a Host header.

Source

pub fn proxy_v1(self) -> Self

Use the PROXY protocol v1 to connect to the backend.

Source

pub fn proxy_v2(self) -> Self

Use the PROXY protocol v2 to connect to the backend.

Source

pub fn tls(self, verify_host: bool, verify_peer: bool) -> Self

Use TLS for the backend connection.

Source

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.

Source

pub fn build( self, ctx: &mut Ctx<'_>, ) -> VclResult<Backend<NativeVclBackendShim, NativeVclResponseShim>>

Build the native backend

Trait Implementations§

Source§

impl<'a> Debug for NativeBackendBuilder<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.