---
title: BackendBuilder
summary: A builder structure for generating a dynamic backend.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/backend/struct.BackendBuilder/
---

**Kind:** Struct  
**Module:** [backend](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/backend/)  
**Package:** fastly 0.13.1  
**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#20

```rust
pub struct BackendBuilder { /* private fields */ }
```

A builder structure for generating a dynamic backend.

This structure can be constructed using either [`Backend::builder()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/backend/struct.Backend/#method-builder) or its
own [`new()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/backend/struct.BackendBuilder/#method-new) method, and will generate a new backend for use by the program after
consuming the `BackendBuilder` with [`finish()`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/backend/struct.BackendBuilder/#method-finish).

## Methods

### between_bytes_timeout

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#171

```rust
fn between_bytes_timeout(self, timeout: Duration) -> Self
```

Set a timeout that applies any two bytes of the body.
Defaults to 10,000ms (10s).

**Parameters**

- `self`: `Self`
- `timeout`: `Duration`

**Returns**

`Self`

### ca_certificate

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#237

```rust
fn ca_certificate(self, value: impl ToString) -> Self
```

Set the CA certificate to use when checking the validity of the
backend. Setting this will enable SSL for the connection as a side
effect.

If ca_certificate is not provided (default), the backends's certificate
is validated using a set of public root CAs.

**Parameters**

- `self`: `Self`
- `value`: `impl ToString`

**Returns**

`Self`

### check_certificate

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#225

```rust
fn check_certificate(self, hostname: impl ToString) -> Self
```

Define the hostname that the server certificate should declare, and
turn on validation during backend connections. You should enable this
if you are using SSL/TLS, and setting this will enable SSL for the
connection as a side effect.

If check_certificate is not provided (default), the server certificate's
hostname may have any value.

**Parameters**

- `self`: `Self`
- `hostname`: `impl ToString`

**Returns**

`Self`

### connect_timeout

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#154

```rust
fn connect_timeout(self, timeout: Duration) -> Self
```

Set the connection timeout for this backend. Defaults to 1,000ms (1s).

**Parameters**

- `self`: `Self`
- `timeout`: `Duration`

**Returns**

`Self`

### disable_ssl

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#197

```rust
fn disable_ssl(self) -> Self
```

Disable SSL/TLS for this backend.

**Parameters**

- `self`: `Self`

**Returns**

`Self`

### enable_pooling

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#291

```rust
fn enable_pooling(self, value: bool) -> Self
```

Determine whether or not connections to the same backend should be pooled
across different sessions.

Fastly considers two backends "the same" if they're registered with the
same name and the exact same settings. In those cases, when pooling is
enabled, if Session 1 opens a connection to this backend it will be left
open, and can be re-used by Session 2. This can help improve backend
latency, by removing the need for the initial network / TLS handshake(s).

By default, pooling is enabled for dynamic backends.

**Parameters**

- `self`: `Self`
- `value`: `bool`

**Returns**

`Self`

### enable_ssl

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#191

```rust
fn enable_ssl(self) -> Self
```

Use SSL/TLS to connect to the backend.

When using SSL/TLS, Fastly checks the validity of the backend's
certificate, and fails the connection if the certificate is invalid.
This check is not optional: an invalid certificate will cause the
backend connection to fail (but read on).

By default, the validity check does not require that the certificate
hostname matches the hostname of your request. You can use
[check_certificate](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/backend/struct.BackendBuilder/#method-check_certificate) to request a check of the
certificate hostname.

By default, certificate validity uses a set of public certificate
authorities. You can specify an alternative CA using
[ca_certificate](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/backend/struct.BackendBuilder/#method-ca_certificate).

**Parameters**

- `self`: `Self`

**Returns**

`Self`

### finish

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#387

```rust
fn finish(self) -> Result<Backend, BackendCreationError>
```

Attempt to register this backend with runtime, returning the backend
for use like any other backends.

In the case that this function returns `BackendCreationError::NameInUse`,
users can use `Backend::from_str` as per normal to create a reference to
that version. (That being said, you should be careful to only use this
capability in situations in which you are 100% sure that this name will
always lead to the same place.)

**Parameters**

- `self`: `Self`

**Returns**

`Result<Backend, BackendCreationError>`

### first_byte_timeout

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#164

```rust
fn first_byte_timeout(self, timeout: Duration) -> Self
```

Set a timeout that applies between the time of sending a request and the time the HTTP
headers are fully received. Defaults to 15,000ms (15s).

The name is, admittedly, confusing; it notionally refers to "first byte of the HTTP body",
though of course not all responses have bodies.

**Parameters**

- `self`: `Self`
- `timeout`: `Duration`

**Returns**

`Self`

### healthcheck

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#371

```rust
fn healthcheck(self, value: HealthcheckBuilder) -> Self
```

Experimental: Add a healthcheck created from `HealthcheckBuilder` to the current dynamic backend.

Note that this feature is experimental, and may be removed or changed without a SemVer breaking change.
This feature is not available to all customers / on all services. If you are interested in trying this feature, please contact your Fastly representative.

**Parameters**

- `self`: `Self`
- `value`: `crate::experimental::dynamic_backend_healthchecks::HealthcheckBuilder`

**Returns**

`Self`

### http_keepalive_time

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#298

```rust
fn http_keepalive_time(self, value: Duration) -> Self
```

Configure up to how long to allow HTTP keepalive connections to remain idle in the
connection pool.

**Parameters**

- `self`: `Self`
- `value`: `Duration`

**Returns**

`Self`

### max_connections

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#345

```rust
fn max_connections(self, value: u32) -> Self
```

Configure how many connections to allow in the connection pool for this backend.

`0` is treated as unlimited. The default is `200`.

Note that this limit is best determined experimentally, since the total number of
connections to the backend will depend on POP sizes, HTTP keepalive limits, and the traffic
patterns for individual POPs.

**Parameters**

- `self`: `Self`
- `value`: `u32`

**Returns**

`Self`

### max_lifetime

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#362

```rust
fn max_lifetime(self, value: Duration) -> Self
```

Configure an upper bound for how long a pooled HTTP keepalive connection is allowed to have
been open before we stop trying to reuse it.

[Duration::ZERO](https://doc.rust-lang.org/stable/core/time/struct.Duration.html#associatedconstant.ZERO) is treated as unlimited. The default is [Duration::ZERO](https://doc.rust-lang.org/stable/core/time/struct.Duration.html#associatedconstant.ZERO).

**Parameters**

- `self`: `Self`
- `value`: `Duration`

**Returns**

`Self`

### max_use

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#353

```rust
fn max_use(self, value: u32) -> Self
```

Configure how many times an HTTP keepalive connection can be reused in a connection pool.

`0` is treated as unlimited. The default is `0`.

**Parameters**

- `self`: `Self`
- `value`: `u32`

**Returns**

`Self`

### new

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#108

```rust
fn new(name: impl ToString, target: impl ToString) -> Self
```

Create a new dynamic backend builder.

The arguments are the name of the new backend to use, along with a string
describing the backend host. The latter can be of the form:

   * `"<ip address>"`
   * `"<hostname>"`
   * `"<ip address>:<port>"`
   * `"<hostname>:<port>"`

The name can be whatever you would like, as long as it does not match the name
of any of the static service backends nor match any other dynamic backends built
during this session. (Names can overlap between different sessions of the same
service -- they will be treated as completely separate entities and will not be
pooled -- but you cannot, for example, declare a dynamic backend named
"dynamic-backend" twice in the same session.)

The builder will start with default values for all other possible fields for the
backend, which can be overridden using the other methods provided. Call
`finish()` to complete the construction of the dynamic backend.

Dynamic backends must be enabled for this Compute service. You can determine
whether or not dynamic backends have been allowed for the current service by
using this builder, and then checking for the `BackendCreationError::Disallowed`
error result. This error only arises when attempting to use dynamic backends
with a service that has not had dynamic backends enabled, or dynamic backends
have been administratively prohibited for the node in response to an ongoing
incident.

**Parameters**

- `name`: `impl ToString`
- `target`: `impl ToString`

**Returns**

`Self`

### override_host

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#148

```rust
fn override_host(self, name: impl ToString) -> Self
```

Set a host header override when contacting this backend.

This will force the value of the "Host" header to the given string when sending out the
origin request. If this is not set and no header already exists, the "Host" header will
default to this builder's target.

For more information, see the Fastly documentation on override hosts here:
<https://docs.fastly.com/en/guides/specifying-an-override-host>

**Parameters**

- `self`: `Self`
- `name`: `impl ToString`

**Returns**

`Self`

### prefer_ipv6

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#333

```rust
fn prefer_ipv6(self, value: bool) -> Self
```

Configure whether to prefer trying IPv6 connections first before IPv4 when a hostname
has both A and AAAA records.

This defaults to `true`.

**Parameters**

- `self`: `Self`
- `value`: `bool`

**Returns**

`Self`

### provide_client_certificate

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#271

```rust
fn provide_client_certificate(self, pem_certificate: impl ToString, pem_key: Secret) -> Self
```

Provide the given client certificate to the server as part of the SSL handshake.
Setting this will enable SSL for the connection as a side effect. Both
the certificate and the key to use should be in standard PEM format;
providing the information in another format will lead to an error. We
suggest that (at least the) key should be held in something like the
Fastly secret store for security, with the handle passed to this function
without unpacking it via [`Secret::plaintext`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/secret_store/struct.Secret/#method-plaintext); the certificate can
be held in a less secure medium.

(If it is absolutely necessary to get the key from another source, we
suggest the use of [`Secret::from_bytes`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/secret_store/struct.Secret/#method-from_bytes)).

**Parameters**

- `self`: `Self`
- `pem_certificate`: `impl ToString`
- `pem_key`: `Secret`

**Returns**

`Self`

### set_max_tls_version

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#212

```rust
fn set_max_tls_version(self, maximum: SslVersion) -> Self
```

Set the maximum TLS version for connecting to the backend. Setting
this will enable SSL for the connection as a side effect.

**Parameters**

- `self`: `Self`
- `maximum`: `SslVersion`

**Returns**

`Self`

### set_min_tls_version

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#204

```rust
fn set_min_tls_version(self, minimum: SslVersion) -> Self
```

Set the minimum TLS version for connecting to the backend. Setting
this will enable SSL for the connection as a side effect.

**Parameters**

- `self`: `Self`
- `minimum`: `SslVersion`

**Returns**

`Self`

### sni_hostname

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#253

```rust
fn sni_hostname(self, value: impl ToString) -> Self
```

Set the SNI hostname for the backend connection. Setting this will
enable SSL for the connection as a side effect.

**Parameters**

- `self`: `Self`
- `value`: `impl ToString`

**Returns**

`Self`

### tcp_keepalive_enable

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#304

```rust
fn tcp_keepalive_enable(self, value: bool) -> Self
```

Configure whether or not to use TCP keepalive on the connection to the backend.

**Parameters**

- `self`: `Self`
- `value`: `bool`

**Returns**

`Self`

### tcp_keepalive_interval_secs

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#310

```rust
fn tcp_keepalive_interval_secs(self, value: NonZeroU32) -> Self
```

Configure how long to wait in between each TCP keepalive probe sent to the backend.

**Parameters**

- `self`: `Self`
- `value`: `NonZeroU32`

**Returns**

`Self`

### tcp_keepalive_probes

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#317

```rust
fn tcp_keepalive_probes(self, value: NonZeroU32) -> Self
```

Configure up to how many TCP keepalive probes to send to the backend before the connection
is considered dead.

**Parameters**

- `self`: `Self`
- `value`: `NonZeroU32`

**Returns**

`Self`

### tcp_keepalive_time_secs

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#324

```rust
fn tcp_keepalive_time_secs(self, value: NonZeroU32) -> Self
```

Configure how long to wait after the last sent data over the TCP connection before
starting to send TCP keepalive probes.

**Parameters**

- `self`: `Self`
- `value`: `NonZeroU32`

**Returns**

`Self`

### tls_ciphers

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#245

```rust
fn tls_ciphers(self, value: impl ToString) -> Self
```

Set the acceptable cipher suites to use for TLS 1.0 - 1.2 connections. Setting
this will enable SSL for the connection as a side effect.

**Parameters**

- `self`: `Self`
- `value`: `impl ToString`

**Returns**

`Self`

## Trait implementations

### impl GrpcBackend for BackendBuilder

#### for_grpc

**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/backend/builder.rs#820

```rust
fn for_grpc(self, value: bool) -> Self
```

**Parameters**

- `self`: `Self`
- `value`: `bool`

**Returns**

`Self`

## Auto trait implementations

- `Freeze`
- `RefUnwindSafe`
- `Send`
- `Sync`
- `Unpin`
- `UnsafeUnpin`
- `UnwindSafe`

## Blanket implementations

- `Any`
- `Borrow<T>`
- `BorrowMut<T>`
- `Downcast`
- `ErasedDestructor`
- `From<T>`
- `Into<U>`
- `IntoEither`
- `Same`
- `TryFrom<U>`
- `TryInto<U>`
