pub struct XdsServer { /* private fields */ }Expand description
The main xDS server.
This server wraps the cache and provides gRPC services for xDS. It includes production-ready features like health checking, metrics, graceful shutdown, and connection tracking.
Implementations§
Source§impl XdsServer
impl XdsServer
Sourcepub fn builder() -> XdsServerBuilder
pub fn builder() -> XdsServerBuilder
Create a new builder for configuring the server.
Sourcepub fn cache(&self) -> &Arc<ShardedCache> ⓘ
pub fn cache(&self) -> &Arc<ShardedCache> ⓘ
Get a reference to the cache.
Sourcepub fn registry(&self) -> &Arc<ResourceRegistry> ⓘ
pub fn registry(&self) -> &Arc<ResourceRegistry> ⓘ
Get a reference to the resource registry.
Sourcepub fn config(&self) -> &ServerConfig
pub fn config(&self) -> &ServerConfig
Get the server configuration.
Sourcepub fn metrics(&self) -> Option<&XdsMetrics>
pub fn metrics(&self) -> Option<&XdsMetrics>
Get the metrics instance, if enabled.
Sourcepub fn shutdown_controller(&self) -> &ShutdownController
pub fn shutdown_controller(&self) -> &ShutdownController
Get the shutdown controller.
Sourcepub fn connections(&self) -> Option<&ConnectionTracker>
pub fn connections(&self) -> Option<&ConnectionTracker>
Get the connection tracker, if enabled.
Sourcepub fn service_state(&self) -> ServiceState
pub fn service_state(&self) -> ServiceState
Create the service state for all discovery services.
Sourcepub async fn serve(self, addr: SocketAddr) -> Result<(), Error>
pub async fn serve(self, addr: SocketAddr) -> Result<(), Error>
Start the server and listen on the given address.
This method will:
- Set up health checking (if enabled)
- Register all xDS services
- Handle graceful shutdown on SIGTERM/SIGINT
§Example
let server = XdsServerBuilder::new()
.cache(cache)
.build()?;
server.serve("[::]:18000".parse()?).await?;Sourcepub async fn serve_with_shutdown(
self,
addr: SocketAddr,
shutdown_rx: Receiver<()>,
) -> Result<(), Error>
pub async fn serve_with_shutdown( self, addr: SocketAddr, shutdown_rx: Receiver<()>, ) -> Result<(), Error>
Start the server with a custom shutdown signal.
This allows you to control shutdown programmatically.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for XdsServer
impl !UnwindSafe for XdsServer
impl Freeze for XdsServer
impl Send for XdsServer
impl Sync for XdsServer
impl Unpin for XdsServer
impl UnsafeUnpin for XdsServer
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
Mutably borrows from an owned value. Read more
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>
Wrap the input message
T in a tonic::Request