pub struct ServerBuilder { /* private fields */ }Expand description
Fluent builder for Server.
Every YAML-visible field on ConfPool has a setter on
ServerBuilder; in addition, hook setters accept boxed trait
objects to plug custom implementations.
§Examples
use dynomite::embed::ServerBuilder;
use dynomite::conf::DataStore;
let server = ServerBuilder::new("dyn_o_mite")
.listen("127.0.0.1:18102".parse().unwrap())
.dyn_listen("127.0.0.1:18101".parse().unwrap())
.data_store(DataStore::Redis)
.servers(vec![dynomite::conf::ConfServer::parse("127.0.0.1:6379:1").unwrap()])
.tokens_str("0")
.build()
.unwrap();
drop(server);Implementations§
Source§impl ServerBuilder
impl ServerBuilder
Sourcepub fn new(pool_name: impl Into<String>) -> Self
pub fn new(pool_name: impl Into<String>) -> Self
Build an empty ServerBuilder for a pool named pool_name.
§Examples
use dynomite::embed::ServerBuilder;
let b = ServerBuilder::new("dyn_o_mite");
assert_eq!(b.pool_name(), "dyn_o_mite");Sourcepub fn from_config(cfg: &Config) -> Self
pub fn from_config(cfg: &Config) -> Self
Build from an existing parsed Config.
§Examples
use dynomite::conf::Config;
use dynomite::embed::ServerBuilder;
let yaml = "p:\n listen: 127.0.0.1:1\n dyn_listen: 127.0.0.1:2\n tokens: '1'\n servers:\n - 127.0.0.1:3:1\n data_store: 0\n";
let cfg = Config::parse_str(yaml).unwrap();
let b = ServerBuilder::from_config(&cfg);
assert_eq!(b.pool_name(), "p");Sourcepub fn from_yaml_file(path: impl AsRef<Path>) -> Result<Self, EmbedError>
pub fn from_yaml_file(path: impl AsRef<Path>) -> Result<Self, EmbedError>
Build by parsing a YAML file.
§Examples
use std::io::Write;
use dynomite::embed::ServerBuilder;
let mut f = tempfile::NamedTempFile::new().unwrap();
writeln!(f, "p:\n listen: 127.0.0.1:1\n dyn_listen: 127.0.0.1:2\n tokens: '1'\n servers:\n - 127.0.0.1:3:1\n data_store: 0").unwrap();
let b = ServerBuilder::from_yaml_file(f.path()).unwrap();
assert_eq!(b.pool_name(), "p");Sourcepub fn with_pool_name(self, name: impl Into<String>) -> Self
pub fn with_pool_name(self, name: impl Into<String>) -> Self
Override the pool name supplied to Self::new.
The C reference accepts only one pool per Config, so the
pool name is part of the constructor for ergonomics. This
setter exists so callers that build a ServerBuilder
from a default-named template ("dyn_o_mite") can rename
the pool without rebuilding the chain. Recorded as
Deviation in docs/parity.md (the design page sketches
a no-arg Server::builder()).
Sourcepub fn listen(self, addr: SocketAddr) -> Self
pub fn listen(self, addr: SocketAddr) -> Self
listen: - client-facing listener address.
Accepts port 0 (kernel-assigned ephemeral port). The
post-bind address is reported via
ServerHandle::listen_addr.
Sourcepub fn dyn_listen(self, addr: SocketAddr) -> Self
pub fn dyn_listen(self, addr: SocketAddr) -> Self
dyn_listen: - peer-facing listener address.
Accepts port 0 (kernel-assigned ephemeral port). The
post-bind address is reported via
ServerHandle::dyn_listen_addr.
Sourcepub fn stats_listen(self, addr: SocketAddr) -> Self
pub fn stats_listen(self, addr: SocketAddr) -> Self
stats_listen: - HTTP stats listener address.
Accepts port 0 for ephemeral-port semantics. Note that
the embedded server does not currently bind the stats
listener; the dynomited binary does. Embedders that want
a Prometheus-style scrape endpoint should plug a
MetricsSink implementation
instead.
Sourcepub fn data_store(self, d: DataStore) -> Self
pub fn data_store(self, d: DataStore) -> Self
data_store: - protocol selector.
Sourcepub fn read_consistency(self, c: ConsistencyLevel) -> Self
pub fn read_consistency(self, c: ConsistencyLevel) -> Self
read_consistency: - quorum policy for reads.
Sourcepub fn write_consistency(self, c: ConsistencyLevel) -> Self
pub fn write_consistency(self, c: ConsistencyLevel) -> Self
write_consistency: - quorum policy for writes.
Sourcepub fn secure_server_option(self, opt: SecureServerOption) -> Self
pub fn secure_server_option(self, opt: SecureServerOption) -> Self
secure_server_option: - inter-node TLS mode.
Sourcepub fn pem_key_file(self, path: impl AsRef<Path>) -> Self
pub fn pem_key_file(self, path: impl AsRef<Path>) -> Self
pem_key_file: - path to the PEM private key.
Sourcepub fn servers(self, servers: Vec<ConfServer>) -> Self
pub fn servers(self, servers: Vec<ConfServer>) -> Self
servers: - the (single-element) datastore list.
Sourcepub fn dyn_seeds(self, seeds: Vec<ConfDynSeed>) -> Self
pub fn dyn_seeds(self, seeds: Vec<ConfDynSeed>) -> Self
dyn_seeds: - peer dynomite nodes.
Sourcepub fn dyn_seed_provider(self, name: impl Into<String>) -> Self
pub fn dyn_seed_provider(self, name: impl Into<String>) -> Self
dyn_seed_provider: - seeds backend selector.
Sourcepub fn auto_eject_hosts(self, on: bool) -> Self
pub fn auto_eject_hosts(self, on: bool) -> Self
auto_eject_hosts: - automatically eject failing peers.
Sourcepub fn server_failure_limit(self, n: u32) -> Self
pub fn server_failure_limit(self, n: u32) -> Self
server_failure_limit: - consecutive failures before eject.
Sourcepub fn server_retry_timeout(self, d: Duration) -> Self
pub fn server_retry_timeout(self, d: Duration) -> Self
server_retry_timeout: - retry interval for ejected servers.
Sourcepub fn gossip_interval(self, d: Duration) -> Self
pub fn gossip_interval(self, d: Duration) -> Self
gos_interval: - gossip period.
Sourcepub fn enable_gossip(self, on: bool) -> Self
pub fn enable_gossip(self, on: bool) -> Self
enable_gossip: - turn the gossip task on or off.
Sourcepub fn datacenter(self, dc: impl Into<String>) -> Self
pub fn datacenter(self, dc: impl Into<String>) -> Self
datacenter: - this node’s datacenter.
Sourcepub fn tokens_str(self, raw: impl AsRef<str>) -> Self
pub fn tokens_str(self, raw: impl AsRef<str>) -> Self
tokens: - this node’s tokens, parsed from the YAML
representation.
Returns the builder unchanged when the tokens string fails
to parse so callers can chain. Parse failures emit a
tracing::warn! event so a typo in the token string is
observable in logs even though it does not break the
chain. Use ServerBuilder::tokens to set a pre-parsed
TokenList when you want a hard error on bad input.
The silent-ignore-with-log behaviour is recorded as a
SemVer-major candidate in docs/parity.md; v0.2 may
switch to a Result-returning variant.
Sourcepub fn read_repairs_enabled(self, on: bool) -> Self
pub fn read_repairs_enabled(self, on: bool) -> Self
read_repairs_enabled: - enable read-repair on quorum
mismatch.
Sourcepub fn client_connections(self, n: u32) -> Self
pub fn client_connections(self, n: u32) -> Self
client_connections: - client connection cap.
Sourcepub fn datastore_connections(self, n: u8) -> Self
pub fn datastore_connections(self, n: u8) -> Self
datastore_connections: - count of datastore-side
connections.
Sourcepub fn local_peer_connections(self, n: u8) -> Self
pub fn local_peer_connections(self, n: u8) -> Self
local_peer_connections: - count of local-DC peer
connections.
Sourcepub fn remote_peer_connections(self, n: u8) -> Self
pub fn remote_peer_connections(self, n: u8) -> Self
remote_peer_connections: - count of remote-DC peer
connections.
Sourcepub fn preconnect(self, on: bool) -> Self
pub fn preconnect(self, on: bool) -> Self
preconnect: - eagerly establish connections at startup.
Sourcepub fn stats_interval(self, d: Duration) -> Self
pub fn stats_interval(self, d: Duration) -> Self
stats_interval: - stats aggregation period.
Sourcepub fn seeds_provider(self, sp: Box<dyn SeedsProvider>) -> Self
pub fn seeds_provider(self, sp: Box<dyn SeedsProvider>) -> Self
Plug a custom SeedsProvider.
Sourcepub fn crypto_provider(self, cp: Box<dyn CryptoProvider>) -> Self
pub fn crypto_provider(self, cp: Box<dyn CryptoProvider>) -> Self
Plug a custom CryptoProvider.
Sourcepub fn metrics_sink(self, ms: Box<dyn MetricsSink>) -> Self
pub fn metrics_sink(self, ms: Box<dyn MetricsSink>) -> Self
Plug a custom MetricsSink.
Sourcepub fn with_vector_registry(self, registry: Arc<VectorRegistry>) -> Self
pub fn with_vector_registry(self, registry: Arc<VectorRegistry>) -> Self
Plug a shared crate::vector::registry::VectorRegistry.
Without this setter the builder installs a fresh,
per-server registry on build(). Embedders that want to
drive multiple servers against a single shared catalog of
indexes (mirroring, fan-out testing, …) can pass an
Arc they constructed elsewhere; the same registry will
then be reachable through
crate::embed::ServerHandle::vector_registry on every
server built with this builder.
§Examples
use std::sync::Arc;
use dynomite::embed::ServerBuilder;
use dynomite::vector::registry::VectorRegistry;
let registry = Arc::new(VectorRegistry::new());
let _b = ServerBuilder::new("p").with_vector_registry(registry);Sourcepub fn vector_registry(&self) -> Option<&Arc<VectorRegistry>>
pub fn vector_registry(&self) -> Option<&Arc<VectorRegistry>>
Borrow the configured crate::vector::registry::VectorRegistry,
if one was supplied via
Self::with_vector_registry. Returns None when the
default-allocated registry will be installed by
Self::build.
Sourcepub fn build(self) -> Result<Server, EmbedError>
pub fn build(self) -> Result<Server, EmbedError>
Build the Server.
Applies defaults to any unset field, runs the validation
pass, fills in any missing hooks with their in-crate
defaults, and constructs the runtime data structures
(cluster pool, dispatcher, stats, event bus). The returned
Server is not running yet; call
Server::start to spawn
background tasks.
Trait Implementations§
Source§impl Debug for ServerBuilder
impl Debug for ServerBuilder
Source§impl Default for ServerBuilder
impl Default for ServerBuilder
Auto Trait Implementations§
impl Freeze for ServerBuilder
impl !RefUnwindSafe for ServerBuilder
impl Send for ServerBuilder
impl Sync for ServerBuilder
impl Unpin for ServerBuilder
impl UnsafeUnpin for ServerBuilder
impl !UnwindSafe for ServerBuilder
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.