pub struct Cluster {Show 23 fields
pub cluster_id: String,
pub sticky_session: bool,
pub https_redirect: bool,
pub proxy_protocol: Option<i32>,
pub load_balancing: i32,
pub answer_503: Option<String>,
pub load_metric: Option<i32>,
pub http2: Option<bool>,
pub answers: BTreeMap<String, String>,
pub https_redirect_port: Option<u32>,
pub authorized_hashes: Vec<String>,
pub www_authenticate: Option<String>,
pub max_connections_per_ip: Option<u64>,
pub retry_after: Option<u32>,
pub health_check: Option<HealthCheckConfig>,
pub udp: Option<UdpClusterConfig>,
pub max_connections_per_subnet: Option<u64>,
pub affinity_header: Option<String>,
pub affinity_cookie: Option<String>,
pub shard_percent: Option<u32>,
pub shard_min_backends: Option<u32>,
pub shard_mode: Option<i32>,
pub max_connection_attempts: Option<u32>,
}Expand description
A cluster is what binds a frontend to backends with routing rules
Fields§
§cluster_id: String§sticky_session: boolwether a connection from a client shall be always redirected to the same backend
https_redirect: bool§proxy_protocol: Option<i32>§load_balancing: i32§answer_503: Option<String>§load_metric: Option<i32>§http2: Option<bool>Backend-capability hint: set to true when THE BACKEND speaks HTTP/2 (h2c or h2+TLS). This does NOT gate H2 acceptance at the frontend — frontend H2 is negotiated via TLS ALPN independently of per-cluster configuration (see alpn_protocols on the listener).
answers: BTreeMap<String, String>Per-cluster HTTP answer template overrides keyed by HTTP status code (e.g. “503”). Override a listener-level answer for this cluster only.
https_redirect_port: Option<u32>Optional explicit port to use when building the Location header for
an https_redirect. When unset, the listener’s effective HTTPS port is
used. Lets operators front a non-standard HTTPS port (e.g. 8443) on
the redirect target while keeping https_redirect = true.
Authorized credentials for HTTP basic authentication. Each entry is
formatted as username:hex(sha256(password)) (lower-case hex). The
mux compares the supplied Authorization: Basic header in
constant-time against the full list. Empty list disables auth even
when a frontend sets required_auth = true — those requests are
rejected with a 401.
www_authenticate: Option<String>Realm string emitted in WWW-Authenticate: Basic realm="…" when an
unauthenticated request is rejected. Treated as an opaque value (no
template substitution). Defaults to a generic realm if unset.
max_connections_per_ip: Option<u64>Per-cluster override for the global max_connections_per_ip.
None (field absent) inherits the global default. Some(0) is
explicit “unlimited for this cluster”. Some(n > 0) overrides with
the cluster-specific limit. Counts are kept per
(cluster_id, source_ip) pair, so two clusters never share a
counter even from the same IP. On a UDP cluster it limits concurrent
flows per datagram source address, per listener; UDP never inherits
the global default.
retry_after: Option<u32>Per-cluster override for the global retry_after header value
(seconds, HTTP 429 only). None inherits the global default.
Some(0) omits the header.
health_check: Option<HealthCheckConfig>Optional HTTP health check configuration for backends in this cluster.
Tag 8 in this message is the http2 backend-capability hint and
tags 9-14 cover answers/redirect/auth/limits, so health-check
configuration occupies tag 15.
udp: Option<UdpClusterConfig>Optional UDP-specific cluster configuration. Present only for clusters that front UDP backends; absent for HTTP/HTTPS/TCP clusters.
max_connections_per_subnet: Option<u64>Per-cluster override for the global max_connections_per_subnet.
Same three-state semantics as max_connections_per_ip above:
None (field absent) inherits the global default, Some(0) is
explicit “unlimited for this cluster”, Some(n > 0) overrides.
This is an INDEPENDENT counter from tag 13, not a replacement:
a connection must satisfy BOTH the per-IP and the per-subnet cap
to be admitted, which is what lets an operator express “10 per IP
AND 100 per /64”. Counts are kept per (cluster_id, masked_ip),
so two clusters never share a counter. The mask itself comes from
the boot-time ServerConfig.subnet_ipv4_prefix /
subnet_ipv6_prefix and is NOT overridable per cluster. A UDP
listener counts flows, as for tag 13.
affinity_header: Option<String>Client affinity key of an HTTP/HTTPS cluster whose load_balancing is
HRW or MAGLEV: the value of this request header, matched
case-insensitively, first occurrence. A request that does not carry it
is keyed on its source IP (the PROXY-protocol source when the listener
expects one). Ignored by every other policy and by TCP clusters, which
always key on the source IP: the main state refuses a cluster that
names a key and serves a TCP frontend. Host and Cookie are refused
(never kept as headers). Mutually exclusive with affinity_cookie. The
key is read only when a new backend connection is dialled; a request
reusing one follows it.
Same as affinity_header, keyed on the raw value of this request
cookie, matched case-sensitively. Mutually exclusive with
affinity_header.
shard_percent: Option<u32>Shuffle sharding (sozu-proxy/sozu#524): restrict each client’s
selection to a shard of k backends, the top k of the rendezvous (HRW)
ranking of its affinity key over the cluster’s primary backends, where
k = max(2, ceil(shard_percent * N / 100)), capped at N. Off when unset.
1..=100. The cluster’s load_balancing policy picks inside the shard.
shard_min_backends: Option<u32>Sharding applies only while the cluster has at least this many primary
backends; below it the cluster selects over all of them. At least 2;
defaults to 8. Requires shard_percent.
shard_mode: Option<i32>What happens when no backend of a client’s shard can take a
connection. Requires shard_percent.
max_connection_attempts: Option<u32>Per-cluster override for the global max_connection_attempts: how
many backend connections a request routed to this cluster may try,
the first included, before it is answered 503 (HTTP) or closed
(TCP). Every failed connection counts: refused, timed out on
connect_timeout, or reporting a socket error. Between 1 and 255.
None (field absent) inherits the global value.
Implementations§
Source§impl Cluster
impl Cluster
Sourcepub fn proxy_protocol(&self) -> ProxyProtocolConfig
pub fn proxy_protocol(&self) -> ProxyProtocolConfig
Returns the enum value of proxy_protocol, or the default if the field is unset or set to an invalid enum value.
Sourcepub fn set_proxy_protocol(&mut self, value: ProxyProtocolConfig)
pub fn set_proxy_protocol(&mut self, value: ProxyProtocolConfig)
Sets proxy_protocol to the provided enum value.
Sourcepub fn load_balancing(&self) -> LoadBalancingAlgorithms
pub fn load_balancing(&self) -> LoadBalancingAlgorithms
Returns the enum value of load_balancing, or the default if the field is set to an invalid enum value.
Sourcepub fn set_load_balancing(&mut self, value: LoadBalancingAlgorithms)
pub fn set_load_balancing(&mut self, value: LoadBalancingAlgorithms)
Sets load_balancing to the provided enum value.
Sourcepub fn answer_503(&self) -> &str
pub fn answer_503(&self) -> &str
Returns the value of answer_503, or the default value if answer_503 is unset.
Sourcepub fn load_metric(&self) -> LoadMetric
pub fn load_metric(&self) -> LoadMetric
Returns the enum value of load_metric, or the default if the field is unset or set to an invalid enum value.
Sourcepub fn set_load_metric(&mut self, value: LoadMetric)
pub fn set_load_metric(&mut self, value: LoadMetric)
Sets load_metric to the provided enum value.
Sourcepub fn http2(&self) -> bool
pub fn http2(&self) -> bool
Returns the value of http2, or the default value if http2 is unset.
Sourcepub fn https_redirect_port(&self) -> u32
pub fn https_redirect_port(&self) -> u32
Returns the value of https_redirect_port, or the default value if https_redirect_port is unset.
Sourcepub fn www_authenticate(&self) -> &str
pub fn www_authenticate(&self) -> &str
Returns the value of www_authenticate, or the default value if www_authenticate is unset.
Sourcepub fn max_connections_per_ip(&self) -> u64
pub fn max_connections_per_ip(&self) -> u64
Returns the value of max_connections_per_ip, or the default value if max_connections_per_ip is unset.
Sourcepub fn retry_after(&self) -> u32
pub fn retry_after(&self) -> u32
Returns the value of retry_after, or the default value if retry_after is unset.
Sourcepub fn max_connections_per_subnet(&self) -> u64
pub fn max_connections_per_subnet(&self) -> u64
Returns the value of max_connections_per_subnet, or the default value if max_connections_per_subnet is unset.
Sourcepub fn affinity_header(&self) -> &str
pub fn affinity_header(&self) -> &str
Returns the value of affinity_header, or the default value if affinity_header is unset.
Returns the value of affinity_cookie, or the default value if affinity_cookie is unset.
Sourcepub fn shard_percent(&self) -> u32
pub fn shard_percent(&self) -> u32
Returns the value of shard_percent, or the default value if shard_percent is unset.
Sourcepub fn shard_min_backends(&self) -> u32
pub fn shard_min_backends(&self) -> u32
Returns the value of shard_min_backends, or the default value if shard_min_backends is unset.
Sourcepub fn shard_mode(&self) -> ShardMode
pub fn shard_mode(&self) -> ShardMode
Returns the enum value of shard_mode, or the default if the field is unset or set to an invalid enum value.
Sourcepub fn set_shard_mode(&mut self, value: ShardMode)
pub fn set_shard_mode(&mut self, value: ShardMode)
Sets shard_mode to the provided enum value.
Sourcepub fn max_connection_attempts(&self) -> u32
pub fn max_connection_attempts(&self) -> u32
Returns the value of max_connection_attempts, or the default value if max_connection_attempts is unset.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Cluster
impl<'de> Deserialize<'de> for Cluster
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Cluster
Source§impl Message for Cluster
impl Message for Cluster
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self. Read moreSource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self.Source§impl Ord for Cluster
impl Ord for Cluster
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Cluster
impl PartialOrd for Cluster
impl StructuralPartialEq for Cluster
Auto Trait Implementations§
impl Freeze for Cluster
impl RefUnwindSafe for Cluster
impl Send for Cluster
impl Sync for Cluster
impl Unpin for Cluster
impl UnsafeUnpin for Cluster
impl UnwindSafe for Cluster
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.