pub enum ClusterCommand {
DataPut {
key: Vec<u8>,
value: Vec<u8>,
},
DataDelete {
key: Vec<u8>,
},
PlaceSplit {
shard_id: ShardId,
split_key: Vec<u8>,
},
PlaceMerge {
left_shard_id: ShardId,
right_shard_id: ShardId,
},
PlaceTransfer {
shard_id: ShardId,
from_node: NodeId,
to_node: NodeId,
},
MembershipAdd {
node_id: NodeId,
address: String,
},
MembershipRemove {
node_id: NodeId,
},
}Expand description
A typed, serialisable view over the raw Command::data bytes in a Raft log
entry.
Use ClusterCommand::encode to produce bytes suitable for
crate::log::Command::new, and ClusterCommand::decode (or the
TryFrom<&[u8]> impl) to reconstruct the command on the receiver side.
Variants§
DataPut
A KV put (data plane, future use).
Fields
DataDelete
A KV delete (data plane, future use).
PlaceSplit
Split a hot shard at split_key.
Fields
PlaceMerge
Merge two adjacent cold shards into one.
Fields
PlaceTransfer
Transfer a shard from one node to another to rebalance load.
Fields
MembershipAdd
Add a cluster member (membership plane).
MembershipRemove
Remove a cluster member (membership plane).
Implementations§
Source§impl ClusterCommand
impl ClusterCommand
Sourcepub fn tag(&self) -> u8
pub fn tag(&self) -> u8
Return the single-byte tag that identifies this variant.
The tag is stored as the first byte of the encoded form and enables O(1) dispatch without deserialising the JSON payload.
Sourcepub fn encode(&self) -> Vec<u8> ⓘ
pub fn encode(&self) -> Vec<u8> ⓘ
Encode the command as [tag_byte][json_bytes].
The result is suitable for use as the data field of a
crate::log::Command.
Sourcepub fn decode(bytes: &[u8]) -> RaftResult<Self>
pub fn decode(bytes: &[u8]) -> RaftResult<Self>
Decode a command from [tag_byte][json_bytes].
Returns an error if the byte slice is empty, the tag is unknown, or the JSON body cannot be deserialised.
Sourcepub fn from_placement_action(action: &PlacementAction) -> Self
pub fn from_placement_action(action: &PlacementAction) -> Self
Convert a crate::placement::PlacementAction into the corresponding ClusterCommand.
PlacementAction variant | ClusterCommand variant |
|---|---|
Split | PlaceSplit |
Merge | PlaceMerge |
Transfer | PlaceTransfer |
Trait Implementations§
Source§impl Clone for ClusterCommand
impl Clone for ClusterCommand
Source§fn clone(&self) -> ClusterCommand
fn clone(&self) -> ClusterCommand
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ClusterCommand
impl Debug for ClusterCommand
Source§impl<'de> Deserialize<'de> for ClusterCommand
impl<'de> Deserialize<'de> for ClusterCommand
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ClusterCommand
Source§impl PartialEq for ClusterCommand
impl PartialEq for ClusterCommand
Source§fn eq(&self, other: &ClusterCommand) -> bool
fn eq(&self, other: &ClusterCommand) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for ClusterCommand
impl Serialize for ClusterCommand
impl StructuralPartialEq for ClusterCommand
Auto Trait Implementations§
impl Freeze for ClusterCommand
impl RefUnwindSafe for ClusterCommand
impl Send for ClusterCommand
impl Sync for ClusterCommand
impl Unpin for ClusterCommand
impl UnsafeUnpin for ClusterCommand
impl UnwindSafe for ClusterCommand
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<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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> 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.