Struct NodeBuilder

Source
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

Source

pub fn new(cluster_path: Option<&str>, shutdown_signal: Receiver<()>) -> Self

Creates a new NodeBuilder with cluster configuration loaded from file

§Arguments
  • cluster_path - Optional path to node-specific cluster configuration
  • shutdown_signal - Watch channel for graceful shutdown signaling
§Panics

Will panic if configuration loading fails (consider returning Result instead)

Source

pub fn from_config( cluster_config: ClusterConfig, shutdown_signal: Receiver<()>, ) -> Self

Constructs NodeBuilder from in-memory cluster configuration

§Arguments
  • cluster_config - Pre-built cluster configuration
  • shutdown_signal - Graceful shutdown notification channel
§Usage
let builder = NodeBuilder::from_config(my_config, shutdown_rx);
Source

pub fn init(node_config: RaftNodeConfig, shutdown_signal: Receiver<()>) -> Self

Core initialization logic shared by all construction paths

Source

pub fn raft_log(self, raft_log: ROF<RaftTypeConfig>) -> Self

Sets a custom Raft log storage implementation

Source

pub fn state_machine(self, state_machine: Arc<SMOF<RaftTypeConfig>>) -> Self

Sets a custom state machine implementation

Source

pub fn state_storage(self, state_storage: SSOF<RaftTypeConfig>) -> Self

Sets a custom state storage implementation

Source

pub fn transport(self, transport: TROF<RaftTypeConfig>) -> Self

Sets a custom network transport implementation

Source

pub fn commit_handler(self, commit_handler: COF<RaftTypeConfig>) -> Self

Sets a custom commit handler implementation

Source

pub fn membership(self, membership: MOF<RaftTypeConfig>) -> Self

Sets a custom membership management implementation

Source

pub fn node_config(self, node_config: RaftNodeConfig) -> Self

Replaces the entire node configuration

Source

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

Source

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.

Source

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

Source

pub fn ready(self) -> Result<Arc<Node<RaftTypeConfig>>>

Returns the built node instance after successful construction.

§Errors

Returns Error::NodeFailedToStartError if build hasn’t completed

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T