- Add BUILD.bazel across tidal, tidal-net, tidal-server, tidalctl for bzlmod build - Add tidal/ crate docs (README, CHANGELOG, CONTRIBUTING, AGENTS, CLAUDE, API, ARCHITECTURE) and ai-lookup reference - Add docker standalone/cluster/deploy images, compose, and prometheus config - Harden WAL (batch format, writer, dedup, diagnostics), text syncer/collectors, and vector registry - Expand tidalctl CLI and tests; restructure WAL/visibility integration test suites - Refine tidal-net transport/client/server and tidal-server cluster/scatter-gather
3.5 KiB
3.5 KiB
Task 05: NodeConfig
Delivers
Add NodeConfig struct to tidal/src/db/config.rs extending Config with cluster fields (role, shard_id, region_id, peer_shards). Defaults produce a single-node config with zero changes to existing embedders.
Complexity: S
Dependencies
- Task 01 (ShardId, RegionId, NodeRole types)
- Task 02 (ShardRouter)
Technical Design
// tidal/src/db/config.rs
/// Cluster configuration for distributed tidalDB deployments.
///
/// Defaults produce a single-node configuration identical to M0-M7 behavior.
/// Embedded deployments that do not set any cluster fields get single-node.
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct NodeConfig {
/// The role of this node.
///
/// Default: `NodeRole::Single` (standalone, accepts reads and writes).
pub role: NodeRole,
/// This node's shard identity.
///
/// Default: `ShardId(0)` (single-node shard).
pub shard_id: ShardId,
/// This node's region identity.
///
/// Default: `RegionId(0)` (single-node region).
pub region_id: RegionId,
/// Shards this node is aware of (including itself).
///
/// Empty for single-node deployments.
pub peer_shards: Vec<ShardId>,
/// Routing strategy for entity-to-shard assignment.
///
/// Default: `ShardRouter::single()` (all entities -> ShardId(0)).
#[serde(skip)]
pub router: ShardRouter,
}
impl Default for NodeConfig {
fn default() -> Self {
Self {
role: NodeRole::Single,
shard_id: ShardId::SINGLE,
region_id: RegionId::SINGLE,
peer_shards: vec![],
router: ShardRouter::single(),
}
}
}
impl NodeConfig {
/// Returns true if this is a standalone single-node deployment.
pub fn is_single_node(&self) -> bool {
self.role == NodeRole::Single
}
/// Returns true if this node accepts writes.
pub fn accepts_writes(&self) -> bool {
matches!(self.role, NodeRole::Single | NodeRole::Leader)
}
}
Integration into Config
// tidal/src/db/config.rs -- extend existing Config struct
pub struct Config {
// ... existing fields ...
/// Cluster configuration. Default: single-node.
pub cluster: NodeConfig,
}
impl Default for Config {
fn default() -> Self {
Self {
// ... existing defaults ...
cluster: NodeConfig::default(),
}
}
}
Builder integration
// TidalDb::builder() -- add optional cluster config method
impl TidalDbBuilder {
/// Configure this instance for distributed deployment.
///
/// Not required for single-node embedded use.
pub fn with_cluster(mut self, config: NodeConfig) -> Self {
self.config.cluster = config;
self
}
}
Acceptance Criteria
NodeConfig::default()producesrole=Single,shard_id=ShardId(0),region_id=RegionId(0),peer_shards=[],router=ShardRouter::single()NodeConfig::is_single_node()returns true forSingle, false forLeader/FollowerNodeConfig::accepts_writes()returns true forSingleandLeader, false forFollowerConfiggains acluster: NodeConfigfield with defaultNodeConfig::default()- All existing tests that construct
Configor useTidalDb::builder()pass unchanged (cluster field defaults to single-node) TidalDbBuilder::with_cluster(config)sets the cluster configcargo clippy -D warningsandcargo fmtpass