Expand description
Public embedding API for the Dynomite engine.
dynomite::embed is the surface an embedding program uses to
construct, run, observe, and shut down a Dynomite engine
in-process. The same surface drives the dynomited binary;
the binary is a thin wrapper around this module rather than a
parallel code path.
§Two-tier API
Server::builderreturns aServerBuilder- a typed, fluent, validated-at-buildbuilder that mirrors every YAML-visiblecrate::conf::ConfPoolfield plus typed setters for hook traits with no YAML form.Server::startreturns immediately; the tokio runtime owns the background work. The caller drives the running server through aServerHandle.
§Hooks
Five public traits expose every cross-cutting concern an embedder may want to override:
hooks::Datastore- backing store (Redis / Memcache / custom).hooks::SeedsProvider- service discovery integration.hooks::CryptoProvider- HSM / KMS integration.hooks::MetricsSink- exporter integration.crate::io::reactor::Transport- already exposed byio::reactor; re-exported here asTransportfor discoverability.
Every trait has at least one default implementation shipped
in-crate, and the crate-root re-exports below mean a typical
embedder writes
use dynomite::embed::{Server, ServerBuilder, ServerHandle};
without reaching into the submodules.
§Examples
use dynomite::embed::{Server, ServerBuilder};
use dynomite::conf::DataStore;
let server: 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")
.build()
.unwrap();
let handle = server.start().await.unwrap();
assert_eq!(handle.peers().len(), 1);
handle.shutdown().await.unwrap();Re-exports§
pub use crate::io::reactor::ConnRole;pub use crate::io::reactor::TcpTransport;pub use crate::io::reactor::Transport;pub use self::builder::ServerBuilder;pub use self::error::EmbedError;pub use self::events::CloseReason;pub use self::events::ConnId;pub use self::events::ConnRoleTag;pub use self::events::EventStream;pub use self::events::PeerDownReason;pub use self::events::PeerId;pub use self::events::ServerEvent;pub use self::extension::CommandExtension;pub use self::extension::HsetOutcome;pub use self::hooks::BoxFuture;pub use self::hooks::CryptoProvider;pub use self::hooks::CryptoProviderError;pub use self::hooks::Datastore;pub use self::hooks::DatastoreError;pub use self::hooks::DnsSeedsProvider;pub use self::hooks::FloridaSeedsProvider;pub use self::hooks::LoggingMetricsSink;pub use self::hooks::MemcacheDatastore;pub use self::hooks::MemoryDatastore;pub use self::hooks::MetricsError;pub use self::hooks::MetricsSink;pub use self::hooks::Protocol;pub use self::hooks::RedisDatastore;pub use self::hooks::RustCryptoProvider;pub use self::hooks::SeedsProvider;pub use self::hooks::SimpleSeedsProvider;pub use self::server::Server;pub use self::server::ServerHandle;pub use self::snapshots::DatacenterSnapshot;pub use self::snapshots::PeerSnapshot;pub use self::snapshots::RackSnapshot;pub use self::snapshots::RingSnapshot;