pub struct NodeBuilder { /* private fields */ }Expand description
Builder pattern implementation for constructing a Raft node with configurable components. Provides a fluent interface to set up node configuration, storage, transport, and other dependencies.
Implementations§
Source§impl NodeBuilder
impl NodeBuilder
Sourcepub fn from_config(
cluster_config: ClusterConfig,
shutdown_signal: Receiver<()>,
) -> Self
pub fn from_config( cluster_config: ClusterConfig, shutdown_signal: Receiver<()>, ) -> Self
Sourcepub fn init(node_config: RaftNodeConfig, shutdown_signal: Receiver<()>) -> Self
pub fn init(node_config: RaftNodeConfig, shutdown_signal: Receiver<()>) -> Self
Core initialization logic shared by all construction paths
Sourcepub fn raft_log(self, raft_log: ROF<RaftTypeConfig>) -> Self
pub fn raft_log(self, raft_log: ROF<RaftTypeConfig>) -> Self
Sets a custom Raft log storage implementation
Sourcepub fn state_machine(self, state_machine: Arc<SMOF<RaftTypeConfig>>) -> Self
pub fn state_machine(self, state_machine: Arc<SMOF<RaftTypeConfig>>) -> Self
Sets a custom state machine implementation
Sourcepub fn state_storage(self, state_storage: SSOF<RaftTypeConfig>) -> Self
pub fn state_storage(self, state_storage: SSOF<RaftTypeConfig>) -> Self
Sets a custom state storage implementation
Sourcepub fn transport(self, transport: TROF<RaftTypeConfig>) -> Self
pub fn transport(self, transport: TROF<RaftTypeConfig>) -> Self
Sets a custom network transport implementation
Sourcepub fn commit_handler(self, commit_handler: COF<RaftTypeConfig>) -> Self
pub fn commit_handler(self, commit_handler: COF<RaftTypeConfig>) -> Self
Sets a custom commit handler implementation
Sourcepub fn membership(self, membership: MOF<RaftTypeConfig>) -> Self
pub fn membership(self, membership: MOF<RaftTypeConfig>) -> Self
Sets a custom membership management implementation
Sourcepub fn node_config(self, node_config: RaftNodeConfig) -> Self
pub fn node_config(self, node_config: RaftNodeConfig) -> Self
Replaces the entire node configuration
Sourcepub fn build(self) -> Self
pub fn build(self) -> Self
Finalizes the builder and constructs the Raft node instance.
Initializes default implementations for any unconfigured components:
- Creates sled-based databases for state machine and logs
- Sets up default gRPC transport
- Initializes commit handling subsystem
- Configures membership management
§Panics
Panics if essential components cannot be initialized
Sourcepub fn start_metrics_server(self, shutdown_signal: Receiver<()>) -> Self
pub fn start_metrics_server(self, shutdown_signal: Receiver<()>) -> Self
Starts the metrics server for monitoring node operations.
Launches a Prometheus endpoint on the configured port.
Sourcepub async fn start_rpc_server(self) -> Self
pub async fn start_rpc_server(self) -> Self
Starts the gRPC server for cluster communication.
§Panics
Panics if node hasn’t been built or address binding fails
Auto Trait Implementations§
impl !Freeze for NodeBuilder
impl !RefUnwindSafe for NodeBuilder
impl Send for NodeBuilder
impl Sync for NodeBuilder
impl Unpin for NodeBuilder
impl !UnwindSafe for NodeBuilder
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> 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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request