-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Group storage configuration types in
StorageTypeConfig
trait
This addresses #938 partially (just the outer API level).
- Loading branch information
Showing
11 changed files
with
121 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//! Compatibility layer for `Raft` with old type parameters. | ||
use crate::storage::RaftLogStorage; | ||
use crate::storage::RaftStateMachine; | ||
use crate::RaftNetworkFactory; | ||
use crate::RaftTypeConfig; | ||
use crate::StorageTypeConfig; | ||
use std::marker::PhantomData; | ||
|
||
/// Default type for storage configuration for compatibility. | ||
/// | ||
/// This type implements [`StorageTypeConfig<C>`] with the supplied types for network, | ||
/// log storage and state machine. | ||
pub struct DefaultStorageConfig<C, N, LS, SM> | ||
where | ||
C: RaftTypeConfig, | ||
N: RaftNetworkFactory<C>, | ||
LS: RaftLogStorage<C>, | ||
SM: RaftStateMachine<C>, | ||
{ | ||
_phantom: PhantomData<(C, N, LS, SM)>, | ||
} | ||
|
||
impl<C, N, LS, SM> StorageTypeConfig<C> for DefaultStorageConfig<C, N, LS, SM> | ||
where | ||
C: RaftTypeConfig, | ||
N: RaftNetworkFactory<C>, | ||
LS: RaftLogStorage<C>, | ||
SM: RaftStateMachine<C>, | ||
{ | ||
type NetworkFactory = N; | ||
type LogStorage = LS; | ||
type StateMachine = SM; | ||
} | ||
|
||
/// Type alias to forward to the new `Raft` implementation. | ||
pub type Raft<C, N, LS, SM> = crate::raft::Raft<C, DefaultStorageConfig<C, N, LS, SM>>; |
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