pub struct Server { /* private fields */ }Expand description
Configured-but-not-running server.
Build one with ServerBuilder,
then call Server::start to spawn the background tasks.
Implementations§
Source§impl Server
impl Server
Sourcepub fn vector_registry(&self) -> &Arc<VectorRegistry> ⓘ
pub fn vector_registry(&self) -> &Arc<VectorRegistry> ⓘ
Borrow the crate::vector::registry::VectorRegistry
this server was built with. The crate::embed::ServerBuilder
installs a fresh registry by default; call
crate::embed::ServerBuilder::with_vector_registry to
share one across multiple servers.
Sourcepub async fn start(self) -> Result<ServerHandle, EmbedError>
pub async fn start(self) -> Result<ServerHandle, EmbedError>
Spawn background tasks on the current tokio runtime and
return a ServerHandle.
start is non-blocking. The returned handle is Clone + Send + Sync.
§In-process only
The embedded server in this stage is in-process only:
the listen: and dyn_listen: sockets bind so that
configured ports are reservable and post-bind reporting
works, but cross-process clients connecting to those
ports see open-then-immediate-close (with a runtime
warning logged on each accept). The sanctioned way to
drive an embedded Server from in-process code is
ServerHandle::inject_request. Cross-process traffic
is supported by the dynomited binary, which wires the
proxy module directly. Wiring the embedded accept loop
to the dispatcher is tracked as a follow-up; the contract
is documented in docs/parity.md.
§Examples
use dynomite::embed::ServerBuilder;
use dynomite::conf::DataStore;
let server = ServerBuilder::new("dyn_o_mite")
.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")
.enable_gossip(false)
.build()
.unwrap();
let handle = server.start().await.unwrap();
handle.shutdown().await.unwrap();Source§impl Server
impl Server
Sourcepub fn builder(pool_name: impl Into<String>) -> ServerBuilder
pub fn builder(pool_name: impl Into<String>) -> ServerBuilder
Convenience entry point.
§Examples
use dynomite::embed::Server;
let _b = Server::builder("dyn_o_mite");Sourcepub async fn start_with(
builder: ServerBuilder,
) -> Result<ServerHandle, EmbedError>
pub async fn start_with( builder: ServerBuilder, ) -> Result<ServerHandle, EmbedError>
One-shot “validate, build, and start” helper.
Equivalent to calling builder.build()?.start().await. The
chained-call form remains available for embedders that
want to inspect the Server before spawning tasks; this
helper exists because most embedders only ever build then
immediately start.
§Errors
Returns the same EmbedError variants that
ServerBuilder::build and Server::start surface.
§Examples
use dynomite::embed::{Server, ServerBuilder};
use dynomite::conf::DataStore;
let builder = ServerBuilder::new("dyn_o_mite")
.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");
let handle = Server::start_with(builder).await.unwrap();
handle.shutdown().await.unwrap();Trait Implementations§
Auto Trait Implementations§
impl Freeze for Server
impl !RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl UnsafeUnpin for Server
impl !UnwindSafe for Server
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> 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.