xds-server 0.1.0

gRPC server implementation for xDS control plane
Documentation

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;

# async fn run() -> Result<(), Box<dyn std::error::Error>> {
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?;
# Ok(())
# }

Production Features

Health Checking

The server implements the gRPC health checking protocol:

# use xds_server::XdsServerBuilder;
# use xds_cache::ShardedCache;
# use std::sync::Arc;
# fn example() -> Result<(), Box<dyn std::error::Error>> {
# let cache = Arc::new(ShardedCache::new());
let _server = XdsServerBuilder::new()
    .cache(cache)
    .enable_health_check()
    .build()?;

// Health status is managed automatically
// Available at grpc.health.v1.Health/Check
# Ok(()) }

Metrics

Prometheus metrics are exposed for monitoring:

# use xds_server::XdsServerBuilder;
# use xds_cache::ShardedCache;
# use std::sync::Arc;
# fn example() -> Result<(), Box<dyn std::error::Error>> {
# let cache = Arc::new(ShardedCache::new());
let _server = XdsServerBuilder::new()
    .cache(cache)
    .enable_metrics()
    .build()?;
# Ok(()) }

Graceful Shutdown

The server supports graceful shutdown with connection draining:

# use xds_server::XdsServerBuilder;
# use xds_cache::ShardedCache;
# use std::sync::Arc;
use std::time::Duration;

# fn example() -> Result<(), Box<dyn std::error::Error>> {
# let cache = Arc::new(ShardedCache::new());
let _server = XdsServerBuilder::new()
    .cache(cache)
    .graceful_shutdown(Duration::from_secs(30))
    .build()?;

// Server will drain connections on SIGTERM/SIGINT
# Ok(()) }