Expand description
Integration with the armour ecosystem (feature armour).
Provides multi-tree database management, schema-versioned migrations, and a binary RPC server compatible with armour-rpc clients.
§Components
Db— manages a directory of named collections with persistent metadata (DbInfo) and sequential ID generation.TreeMeta— static descriptor for a collection (name, key scheme, type, version).Db::open_typed_tree/Db::open_typed_map/Db::open_zero_tree/Db::open_zero_map— open a tree or map with automatic migration when the stored schema version differs fromTreeMeta::version.RpcHandler— trait for handling binary RPC requests per collection.TypedTreeHandler—RpcHandlerimplementation that bridges bytes-level RPC to aTypedTreevia aCodec.TreeMap—Arc<HashMap<u64, Arc<dyn RpcHandler>>>routing table (key =xxh3(name)).
§Quick start
ⓘ
use std::sync::Arc;
use armdb::armour::{Db, TypedTreeHandler, TreeMap};
use armdb::RapiraCodec;
let db = Db::open("data/myapp")?;
let tree = Arc::new(db.open_typed_tree::<User, _>(RapiraCodec, &[])?);
// Register handler and start RPC server
let trees: TreeMap = Arc::new(/* hashname -> handler */);
db.listen_tcp(trees.clone(), "127.0.0.1:9000");
db.listen_uds(trees, "/tmp/myapp.sock");§RPC protocol
Length-delimited frames over TCP or Unix socket. Each request carries an
opcode, a collection hashname (xxh3 of the collection name), and an
operation-specific payload. See rpc module for codec details.
Graceful shutdown: Ctrl-C sends a broadcast via async_broadcast;
all accept loops and active connections terminate.
Re-exports§
pub use crate::CollectionMeta;pub use crate::Key;pub use crate::TreeMeta;pub use collection::Collection;pub use handler::RpcHandler;pub use handler::TypedMapHandler;pub use handler::TypedTreeHandler;pub use handler::ZeroMapHandler;pub use handler::ZeroTreeHandler;pub use migration::TypedMigration;pub use migration::TypedMigrationFn;pub use migration::ZeroMigration;pub use migration::ZeroMigrationFn;pub use rpc::TreeMap;pub use seq::SeqGen;pub use tree_db::CollectionInfo;pub use tree_db::Db;pub use tree_db::DbInfo;pub use typed_client::TypedRpcClient;