pub struct ServerHandle { /* private fields */ }Expand description
Cloneable handle to a running Server.
The handle is the public control surface: shutdown, reload, stats, events, request injection, topology snapshots.
Implementations§
Source§impl ServerHandle
impl ServerHandle
Sourcepub fn crypto_provider(&self) -> Option<&dyn CryptoProvider>
pub fn crypto_provider(&self) -> Option<&dyn CryptoProvider>
Borrow the configured CryptoProvider, if one was
plugged. The default builder does not install one.
Sourcepub fn vector_registry(&self) -> Arc<VectorRegistry> ⓘ
pub fn vector_registry(&self) -> Arc<VectorRegistry> ⓘ
Borrow the crate::vector::registry::VectorRegistry
installed at build time. The default builder installs a
fresh, empty registry; share one across servers via
crate::embed::ServerBuilder::with_vector_registry.
Sourcepub fn listen_addr(&self) -> Option<SocketAddr>
pub fn listen_addr(&self) -> Option<SocketAddr>
Local listen address (post-bind), if a listen: was
configured.
Sourcepub fn dyn_listen_addr(&self) -> Option<SocketAddr>
pub fn dyn_listen_addr(&self) -> Option<SocketAddr>
Local dnode listen address (post-bind), if a
dyn_listen: was configured.
Sourcepub fn subscribe_events(&self) -> EventStream
pub fn subscribe_events(&self) -> EventStream
Subscribe to the ServerEvent broadcast.
§Examples
let server = ServerBuilder::new("p")
.listen("127.0.0.1:0".parse().unwrap())
.dyn_listen("127.0.0.1:0".parse().unwrap())
.data_store(DataStore::Redis)
.servers(vec![dynomite::conf::ConfServer::parse("127.0.0.1:6379:1").unwrap()])
.tokens_str("0")
.build().unwrap();
let handle = server.start().await.unwrap();
let _events = handle.subscribe_events();
handle.shutdown().await.unwrap();Sourcepub fn events(&self) -> Arc<EventManager> ⓘ
pub fn events(&self) -> Arc<EventManager> ⓘ
Borrow the EventManager handle that publishes
structured cluster-event payloads (PeerUp, PeerDown,
GossipRoundComplete, etc.).
Returned as Arc so embedders can hold a long-lived
reference and pass it across crate boundaries (notably to
dyniak, which publishes AAE start/complete events).
Sourcepub fn stats_handle(&self) -> Arc<Stats> ⓘ
pub fn stats_handle(&self) -> Arc<Stats> ⓘ
Borrow the live Stats aggregator as a shared handle.
Returns the same Arc<Stats> the runtime publishes to,
so an embedder can read counters as they update without
going through the periodic snapshot path. Useful for
in-process metrics integrations that prefer a pull model
(Prometheus scrape, OpenTelemetry pull readers) over the
push-on-flush path exposed by MetricsSink.
The returned handle is Clone; callers may share it
across threads. The aggregator outlives the handle for as
long as the ServerHandle tree is alive.
Sourcepub fn describe_stats(&self) -> Vec<MetricSpec>
pub fn describe_stats(&self) -> Vec<MetricSpec>
Manifest of every metric the engine emits.
Sourcepub fn peers(&self) -> Vec<PeerSnapshot>
pub fn peers(&self) -> Vec<PeerSnapshot>
Snapshot of every peer in the cluster.
Sourcepub fn datacenters(&self) -> Vec<DatacenterSnapshot>
pub fn datacenters(&self) -> Vec<DatacenterSnapshot>
Snapshot of every datacenter and its racks.
Sourcepub fn ring(&self) -> RingSnapshot
pub fn ring(&self) -> RingSnapshot
Snapshot of the token ring.
Sourcepub async fn inject_request(&self, req: Msg) -> Result<Msg, EmbedError>
pub async fn inject_request(&self, req: Msg) -> Result<Msg, EmbedError>
Inject a parsed request as if it had arrived from a client. Returns the response message.
This is the test/embedding entry point that bypasses the
proxy listener. The dispatcher computes a routing plan; if
the plan resolves to the local datastore, the
Datastore::dispatch
hook is invoked. If the plan resolves to a remote peer
co-located in the same process (via the in-process
registry), the request is forwarded to that peer’s
datastore and its response is returned.
Sourcepub async fn reload(&self, cfg: Config) -> Result<(), EmbedError>
pub async fn reload(&self, cfg: Config) -> Result<(), EmbedError>
Reload the configuration. Validates the new Config
before any state is touched; on failure the running config
is left untouched.
This is the in-process equivalent of SIGHUP. The C
reference’s dynomite_reload_conf (in
_/dynomite/src/dynomite.c) re-reads the YAML from disk;
the embedding API takes the Config directly.
Sourcepub async fn shutdown(&self) -> Result<(), EmbedError>
pub async fn shutdown(&self) -> Result<(), EmbedError>
Graceful shutdown.
Cancels every background task, deregisters from the
in-process peer registry, drains the join set, and
returns. Idempotent: calling shutdown after a previous
shutdown (or after ServerHandle::join returned)
completes successfully without doing any work.
Sourcepub async fn join(&self)
pub async fn join(&self)
Wait for every background task to complete.
Unlike ServerHandle::shutdown, join does not request
cancellation: it parks the caller until the runtime tasks
(gossip, stats aggregator, accept loops, metrics flusher)
finish on their own. The intended use is the
“start-then-park” pattern in long-running embedders that
drive shutdown from a separate signal handler:
let handle = ServerBuilder::new("p")
.listen("127.0.0.1:0".parse().unwrap())
.dyn_listen("127.0.0.1:0".parse().unwrap())
.data_store(DataStore::Redis)
.servers(vec![dynomite::conf::ConfServer::parse("127.0.0.1:6379:1").unwrap()])
.tokens_str("0")
.build().unwrap()
.start().await.unwrap();
let shutdown = handle.clone();
tokio::spawn(async move {
// Replace with `tokio::signal::ctrl_c().await.unwrap();`
// in a real embedder.
shutdown.shutdown().await.unwrap();
});
handle.join().await;join resolves once every task spawned by
Server::start has returned. Calling join repeatedly
is safe; the second call returns immediately because the
task set is drained on the first.
Trait Implementations§
Source§impl Clone for ServerHandle
impl Clone for ServerHandle
Source§fn clone(&self) -> ServerHandle
fn clone(&self) -> ServerHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ServerHandle
impl !RefUnwindSafe for ServerHandle
impl Send for ServerHandle
impl Sync for ServerHandle
impl Unpin for ServerHandle
impl UnsafeUnpin for ServerHandle
impl !UnwindSafe for ServerHandle
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.