pub struct XdsServerBuilder { /* private fields */ }Expand description
Builder for creating an XdsServer.
§Example
use xds_server::XdsServerBuilder;
use xds_cache::ShardedCache;
use std::sync::Arc;
use std::time::Duration;
let cache = Arc::new(ShardedCache::new());
let _server = XdsServerBuilder::new()
.cache(cache)
.enable_sotw()
.enable_delta()
.enable_health_check()
.enable_metrics()
.graceful_shutdown(Duration::from_secs(30))
.max_concurrent_streams(200)
.build()?;Implementations§
Source§impl XdsServerBuilder
impl XdsServerBuilder
Sourcepub fn cache(self, cache: Arc<ShardedCache>) -> Self
pub fn cache(self, cache: Arc<ShardedCache>) -> Self
Set the cache to use.
This is required.
Sourcepub fn registry(self, registry: Arc<ResourceRegistry>) -> Self
pub fn registry(self, registry: Arc<ResourceRegistry>) -> Self
Set the resource registry.
If not set, a default registry will be created.
Sourcepub fn enable_sotw(self) -> Self
pub fn enable_sotw(self) -> Self
Enable State-of-the-World protocol (enabled by default).
Sourcepub fn disable_sotw(self) -> Self
pub fn disable_sotw(self) -> Self
Disable State-of-the-World protocol.
Sourcepub fn enable_delta(self) -> Self
pub fn enable_delta(self) -> Self
Enable Delta xDS protocol.
Sourcepub fn disable_delta(self) -> Self
pub fn disable_delta(self) -> Self
Disable Delta xDS protocol.
Sourcepub fn max_concurrent_streams(self, max: u32) -> Self
pub fn max_concurrent_streams(self, max: u32) -> Self
Set maximum concurrent streams per connection.
Sourcepub fn keepalive_interval(self, interval: Duration) -> Self
pub fn keepalive_interval(self, interval: Duration) -> Self
Set keepalive interval.
Sourcepub fn keepalive_timeout(self, timeout: Duration) -> Self
pub fn keepalive_timeout(self, timeout: Duration) -> Self
Set keepalive timeout.
Sourcepub fn max_request_size(self, size: usize) -> Self
pub fn max_request_size(self, size: usize) -> Self
Set maximum request size in bytes.
Sourcepub fn enable_compression(self) -> Self
pub fn enable_compression(self) -> Self
Enable gzip compression for responses.
Sourcepub fn compression(self, config: CompressionConfig) -> Self
pub fn compression(self, config: CompressionConfig) -> Self
Set custom compression configuration.
Sourcepub fn enable_health_check(self) -> Self
pub fn enable_health_check(self) -> Self
Enable gRPC health checking (enabled by default).
Sourcepub fn disable_health_check(self) -> Self
pub fn disable_health_check(self) -> Self
Disable gRPC health checking.
Sourcepub fn enable_metrics(self) -> Self
pub fn enable_metrics(self) -> Self
Enable Prometheus metrics (enabled by default).
Sourcepub fn disable_metrics(self) -> Self
pub fn disable_metrics(self) -> Self
Disable Prometheus metrics.
Sourcepub fn enable_connection_tracking(self) -> Self
pub fn enable_connection_tracking(self) -> Self
Enable connection tracking (enabled by default).
Sourcepub fn disable_connection_tracking(self) -> Self
pub fn disable_connection_tracking(self) -> Self
Disable connection tracking.
Sourcepub fn graceful_shutdown(self, grace_period: Duration) -> Self
pub fn graceful_shutdown(self, grace_period: Duration) -> Self
Set the graceful shutdown grace period.
During shutdown, the server will:
- Stop accepting new connections
- Mark health as not serving
- Wait for existing connections to drain (up to grace period)
- Force close remaining connections
Sourcepub fn connection_limits(self, limits: ConnectionLimits) -> Self
pub fn connection_limits(self, limits: ConnectionLimits) -> Self
Set connection limits.
Controls maximum total connections and per-IP limits.
Sourcepub fn max_connections(self, max: u64) -> Self
pub fn max_connections(self, max: u64) -> Self
Set maximum total connections.
Sourcepub fn max_connections_per_ip(self, max: u64) -> Self
pub fn max_connections_per_ip(self, max: u64) -> Self
Set maximum connections per IP address.
Sourcepub fn tls_config(self, config: ServerTlsConfig) -> Self
Available on crate feature tls only.
pub fn tls_config(self, config: ServerTlsConfig) -> Self
tls only.Configure TLS (and optionally mTLS) for the gRPC server.
Pass a tonic::transport::ServerTlsConfig populated with the server
identity (identity()) and, for mTLS, the client CA
(client_ca_root() / client_auth_optional()).
§Example
use tonic::transport::{Identity, ServerTlsConfig};
let cert = std::fs::read("server.pem")?;
let key = std::fs::read("server.key")?;
let tls = ServerTlsConfig::new().identity(Identity::from_pem(cert, key));
let _server = XdsServerBuilder::new()
.cache(cache)
.tls_config(tls)
.build()?;Available only when the tls feature is enabled.
Trait Implementations§
Source§impl Debug for XdsServerBuilder
impl Debug for XdsServerBuilder
Auto Trait Implementations§
impl !RefUnwindSafe for XdsServerBuilder
impl !UnwindSafe for XdsServerBuilder
impl Freeze for XdsServerBuilder
impl Send for XdsServerBuilder
impl Sync for XdsServerBuilder
impl Unpin for XdsServerBuilder
impl UnsafeUnpin for XdsServerBuilder
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request