Skip to main content

Crate xds_server

Crate xds_server 

Source
Expand description

§xds-server

xDS gRPC server implementation for control planes.

This crate provides the gRPC server layer for xDS:

  • XdsServer - Main server type wrapping all xDS services
  • XdsServerBuilder - Builder for configuring the server
  • State-of-the-World (SotW) protocol support
  • Delta xDS protocol support (incremental updates)
  • Health checking via gRPC health protocol
  • Prometheus metrics for observability
  • Graceful shutdown with connection draining
  • Connection tracking and limits

§Example

use xds_server::XdsServerBuilder;
use xds_cache::ShardedCache;
use std::sync::Arc;

let cache = Arc::new(ShardedCache::new());
let server = XdsServerBuilder::new()
    .cache(cache)
    .enable_sotw()
    .enable_delta()
    .enable_health_check()
    .enable_metrics()
    .build()?;

// Use with tonic - includes health and metrics
server.serve("[::]:18000".parse()?).await?;

§Production Features

§Health Checking

The server implements the gRPC health checking protocol:

let _server = XdsServerBuilder::new()
    .cache(cache)
    .enable_health_check()
    .build()?;

// Health status is managed automatically
// Available at grpc.health.v1.Health/Check

§Metrics

Prometheus metrics are exposed for monitoring:

let _server = XdsServerBuilder::new()
    .cache(cache)
    .enable_metrics()
    .build()?;

§Graceful Shutdown

The server supports graceful shutdown with connection draining:

use std::time::Duration;

let _server = XdsServerBuilder::new()
    .cache(cache)
    .graceful_shutdown(Duration::from_secs(30))
    .build()?;

// Server will drain connections on SIGTERM/SIGINT

Re-exports§

pub use connections::ConnectionGuard;
pub use connections::ConnectionLimits;
pub use connections::ConnectionTracker;
pub use health::HealthConfig;
pub use health::HealthService;
pub use metrics::XdsMetrics;
pub use reflection::ReflectionConfig;reflection
pub use reflection::ReflectionService;reflection
pub use shutdown::ShutdownConfig;
pub use shutdown::ShutdownController;

Modules§

connections
Connection tracking and limits.
health
Health service for gRPC health checking protocol.
metrics
Prometheus metrics for xDS server.
reflection
gRPC Server Reflection support for xDS services.
services
gRPC service implementations for xDS.
shutdown
Graceful shutdown handling for the xDS server.
streaming
Shared streaming helpers for xDS discovery services.
utils
Shared utilities for xds-server.

Structs§

ServerConfig
Configuration for the xDS server.
ServerTlsConfigtls
Configures TLS settings for servers.
StreamContext
Context for an active xDS stream.
StreamId
Unique identifier for a stream.
TlsIdentitytls
Represents a private key and X509 certificate.
XdsServer
The main xDS server.
XdsServerBuilder
Builder for creating an XdsServer.