pub struct ClusterHandle { /* private fields */ }Expand description
An opaque handle to the running cluster layer.
Callers obtain it via ClusterHandle::start (multi-node Raft) or
ClusterHandle::start_standalone (single-node, no Raft).
Implementations§
Source§impl ClusterHandle
impl ClusterHandle
Sourcepub async fn start(
node_id: u64,
peers: Vec<(u64, SocketAddr)>,
) -> ServerResult<Self>
pub async fn start( node_id: u64, peers: Vec<(u64, SocketAddr)>, ) -> ServerResult<Self>
Start the Raft node for multi-node operation.
peers must contain at least 3 (node_id, address) pairs (including
this node) because the Raft quorum algorithm requires an odd-sized
cluster of ≥ 3. The addresses are stored for use by the RPC transport
(Phase 8 work).
Sourcepub async fn start_standalone(node_id: u64) -> ServerResult<Self>
pub async fn start_standalone(node_id: u64) -> ServerResult<Self>
Start in standalone (single-node) mode — no Raft, always leader.
This path does not create a RaftNode (which would fail for < 3
peers) and simply returns a sentinel that reports is_leader = true.
Sourcepub fn is_leader(&self) -> bool
pub fn is_leader(&self) -> bool
Returns true when this node currently believes it is the Raft leader.
Sourcepub fn shard_count(&self) -> usize
pub fn shard_count(&self) -> usize
Number of shards tracked by the placement registry.
Returns 0 when running in standalone mode or without the cluster feature.
Sourcepub fn raft_node(&self) -> Option<Arc<RaftNode>>
pub fn raft_node(&self) -> Option<Arc<RaftNode>>
Expose the underlying RaftNode for advanced use.
Sourcepub fn shard_registry(&self) -> Option<Arc<ShardRegistry>>
pub fn shard_registry(&self) -> Option<Arc<ShardRegistry>>
Expose the underlying ShardRegistry for advanced use.
Sourcepub fn list_shards(&self) -> Vec<ShardMetadata>
pub fn list_shards(&self) -> Vec<ShardMetadata>
List all shards currently registered in the placement layer.
Returns an empty Vec when running in standalone mode.
Sourcepub fn shards_on_node(&self, node_id: NodeId) -> Vec<ShardMetadata>
pub fn shards_on_node(&self, node_id: NodeId) -> Vec<ShardMetadata>
List shards currently assigned to a specific node.
Returns an empty Vec when running in standalone mode.
Sourcepub fn find_shard_for_key(&self, key: &Key) -> Option<ShardMetadata>
pub fn find_shard_for_key(&self, key: &Key) -> Option<ShardMetadata>
Find the shard responsible for a given key.
Returns None when running in standalone mode.
Sourcepub fn propose_split(
&self,
shard_id: ShardId,
split_key: Key,
) -> ServerResult<LogIndex>
pub fn propose_split( &self, shard_id: ShardId, split_key: Key, ) -> ServerResult<LogIndex>
Propose a shard split via Raft (leader only).
Returns Err(ServerError::Cluster("NotLeader: ...")) if this node is
not the current Raft leader.
Sourcepub fn propose_merge(
&self,
left_shard_id: ShardId,
right_shard_id: ShardId,
) -> ServerResult<LogIndex>
pub fn propose_merge( &self, left_shard_id: ShardId, right_shard_id: ShardId, ) -> ServerResult<LogIndex>
Propose a shard merge via Raft (leader only).
Returns Err(ServerError::Cluster("NotLeader: ...")) if this node is
not the current Raft leader.
Sourcepub fn propose_transfer(
&self,
shard_id: ShardId,
from_node: NodeId,
to_node: NodeId,
) -> ServerResult<LogIndex>
pub fn propose_transfer( &self, shard_id: ShardId, from_node: NodeId, to_node: NodeId, ) -> ServerResult<LogIndex>
Propose a shard transfer via Raft (leader only).
Returns Err(ServerError::Cluster("NotLeader: ...")) if this node is
not the current Raft leader.
Auto Trait Implementations§
impl !RefUnwindSafe for ClusterHandle
impl !UnwindSafe for ClusterHandle
impl Freeze for ClusterHandle
impl Send for ClusterHandle
impl Sync for ClusterHandle
impl Unpin for ClusterHandle
impl UnsafeUnpin for ClusterHandle
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§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::RequestSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.