-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change: Consolidate
RaftState
type parameters into C
The `RaftState` type, along with related metric types, previously used separate type parameters (`NID`, `N`, `I`) which have now been replaced with a single generic parameter `C` bound by `RaftTypeConfig`. This modification simplifies the type signatures and usage. Upgrade tip: To adapt to this change, update the usage of `RaftState` type parameters from separate `NID`, `N`, `I` to the single generic `C` constrained by `RaftTypeConfig`: ```rust RaftState<NID, N, I> --> RaftState<C> ```
- Loading branch information
1 parent
b3c1f46
commit 01fcb35
Showing
19 changed files
with
102 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
use std::io::Cursor; | ||
|
||
use crate::Node; | ||
use crate::RaftTypeConfig; | ||
use crate::TokioRuntime; | ||
|
||
/// Trivial Raft type config for Engine related unit test. | ||
/// Trivial Raft type config for Engine related unit tests, | ||
/// with an optional custom node type `N` for Node type. | ||
#[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Ord, PartialOrd)] | ||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] | ||
pub(crate) struct UTConfig {} | ||
impl RaftTypeConfig for UTConfig { | ||
pub(crate) struct UTConfig<N = ()> { | ||
_p: std::marker::PhantomData<N>, | ||
} | ||
impl<N> RaftTypeConfig for UTConfig<N> | ||
where N: Node + Copy + Ord | ||
{ | ||
type D = (); | ||
type R = (); | ||
type NodeId = u64; | ||
type Node = (); | ||
type Entry = crate::Entry<UTConfig>; | ||
type Node = N; | ||
type Entry = crate::Entry<Self>; | ||
type SnapshotData = Cursor<Vec<u8>>; | ||
type AsyncRuntime = TokioRuntime; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
//! Defines API for application to send request to access Raft core. | ||
use crate::type_config::alias::InstantOf; | ||
use crate::type_config::alias::NodeIdOf; | ||
use crate::type_config::alias::NodeOf; | ||
use crate::OptionalSend; | ||
use crate::RaftState; | ||
use crate::RaftTypeConfig; | ||
|
||
pub trait BoxCoreFnInternal<C>: FnOnce(&RaftState<NodeIdOf<C>, NodeOf<C>, InstantOf<C>>) + OptionalSend | ||
pub trait BoxCoreFnInternal<C>: FnOnce(&RaftState<C>) + OptionalSend | ||
where C: RaftTypeConfig | ||
{ | ||
} | ||
|
||
impl<C: RaftTypeConfig, T: FnOnce(&RaftState<NodeIdOf<C>, NodeOf<C>, InstantOf<C>>) + OptionalSend> BoxCoreFnInternal<C> | ||
for T | ||
{ | ||
} | ||
impl<C: RaftTypeConfig, T: FnOnce(&RaftState<C>) + OptionalSend> BoxCoreFnInternal<C> for T {} | ||
|
||
/// Boxed trait object for external request function run in `RaftCore` task. | ||
pub(crate) type BoxCoreFn<C> = Box<dyn BoxCoreFnInternal<C> + 'static>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.