pub struct NodeBuilder<SE, SM>{ /* 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<SE, SM> NodeBuilder<SE, SM>
impl<SE, SM> NodeBuilder<SE, SM>
Sourcepub fn from_cluster_config(
cluster_config: ClusterConfig,
shutdown_signal: Receiver<()>,
) -> Self
pub fn from_cluster_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 storage_engine(self, storage_engine: Arc<SE>) -> Self
pub fn storage_engine(self, storage_engine: Arc<SE>) -> Self
Sets a custom storage engine implementation
Sourcepub fn state_machine(self, state_machine: Arc<SM>) -> Self
pub fn state_machine(self, state_machine: Arc<SM>) -> Self
Sets a custom state machine 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 raft_config(self, config: RaftConfig) -> Self
pub fn raft_config(self, config: RaftConfig) -> Self
Replaces the raft 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 file-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 with_custom_state_machine_handler(
self,
handler: Arc<SMHOF<RaftTypeConfig<SE, SM>>>,
) -> Self
pub fn with_custom_state_machine_handler( self, handler: Arc<SMHOF<RaftTypeConfig<SE, SM>>>, ) -> Self
Sets a custom state machine handler implementation.
This allows developers to provide their own implementation of the state machine handler which processes committed log entries and applies them to the state machine.
§Arguments
handler
- custom state machine handler that must implement theStateMachineHandler
trait
§Notes
- The handler must be thread-safe as it will be shared across multiple threads
- If not set, a default implementation will be used during
build()
- The handler should properly handle snapshot creation and restoration
pub fn set_snapshot_policy( self, snapshot_policy: SNP<RaftTypeConfig<SE, SM>>, ) -> Self
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<SE, SM> !Freeze for NodeBuilder<SE, SM>
impl<SE, SM> !RefUnwindSafe for NodeBuilder<SE, SM>
impl<SE, SM> Send for NodeBuilder<SE, SM>
impl<SE, SM> Sync for NodeBuilder<SE, SM>
impl<SE, SM> Unpin for NodeBuilder<SE, SM>
impl<SE, SM> !UnwindSafe for NodeBuilder<SE, SM>
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