pub struct BackendBuilder { /* private fields */ }
Expand description
A builder structure for generating a dynamic backend.
This structure can be constructed using either Backend::builder()
or its
own new()
method, and will generate a new backend for use by the program after
consuming the BackendBuilder
with finish()
.
Implementations§
Source§impl BackendBuilder
impl BackendBuilder
Sourcepub fn new(name: impl ToString, target: impl ToString) -> Self
pub 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.
Sourcepub fn override_host(self, name: impl ToString) -> Self
pub 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
Sourcepub fn connect_timeout(self, timeout: Duration) -> Self
pub fn connect_timeout(self, timeout: Duration) -> Self
Set the connection timeout for this backend. Defaults to 1,000ms (1s).
Sourcepub fn first_byte_timeout(self, timeout: Duration) -> Self
pub fn first_byte_timeout(self, timeout: Duration) -> Self
Set a timeout that applies between the time of connection and the time we get the first byte back. Defaults to 15,000ms (15s).
Sourcepub fn between_bytes_timeout(self, timeout: Duration) -> Self
pub fn between_bytes_timeout(self, timeout: Duration) -> Self
Set a timeout that applies between any two bytes we receive across the wire. Defaults to 10,000ms (10s).
Sourcepub fn enable_ssl(self) -> Self
pub fn enable_ssl(self) -> Self
Use SSL/TLS to connect to the backend.
Sourcepub fn disable_ssl(self) -> Self
pub fn disable_ssl(self) -> Self
Disable SSL/TLS for this backend.
Sourcepub fn set_min_tls_version(self, minimum: SslVersion) -> Self
pub 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.
Sourcepub fn set_max_tls_version(self, maximum: SslVersion) -> Self
pub 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.
Sourcepub fn check_certificate(self, hostname: impl ToString) -> Self
pub 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.
Sourcepub fn ca_certificate(self, value: impl ToString) -> Self
pub 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.
Sourcepub fn tls_ciphers(self, value: impl ToString) -> Self
pub fn tls_ciphers(self, value: impl ToString) -> Self
Set the acceptable cipher suites to use for an SSL connection. Setting this will enable SSL for the connection as a side effect.
Sourcepub fn sni_hostname(self, value: impl ToString) -> Self
pub 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.
Sourcepub fn provide_client_certificate(
self,
pem_certificate: impl ToString,
pem_key: Secret,
) -> Self
pub 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
; 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
).
Sourcepub fn enable_pooling(self, value: bool) -> Self
pub 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.
Sourcepub fn http_keepalive_time(self, value: Duration) -> Self
pub 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.
Sourcepub fn tcp_keepalive_enable(self, value: bool) -> Self
pub fn tcp_keepalive_enable(self, value: bool) -> Self
Configure whether or not to use TCP keepalive on the connection to the backend.
Sourcepub fn tcp_keepalive_interval_secs(self, value: NonZeroU32) -> Self
pub fn tcp_keepalive_interval_secs(self, value: NonZeroU32) -> Self
Configure how long to wait in between each TCP keepalive probe sent to the backend.
Sourcepub fn tcp_keepalive_probes(self, value: NonZeroU32) -> Self
pub 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.
Sourcepub fn tcp_keepalive_time_secs(self, value: NonZeroU32) -> Self
pub 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.
Sourcepub fn finish(self) -> Result<Backend, BackendCreationError>
pub 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.)
Trait Implementations§
Source§impl GrpcBackend for BackendBuilder
impl GrpcBackend for BackendBuilder
Auto Trait Implementations§
impl !Freeze for BackendBuilder
impl !RefUnwindSafe for BackendBuilder
impl Send for BackendBuilder
impl !Sync for BackendBuilder
impl Unpin for BackendBuilder
impl UnwindSafe for BackendBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more