-
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.
If a `RaftNetwork` implmentation found an `AppendEntriesRequest` is too large, it could return a `PayloadTooLarge::new_entries_hint(n)` error to tell openraft devide request into smaller chunks containing at most `n` entries. Openraft will limit the number of entries in the next 10 `AppendEntrie` RPC. Exmaple: ```rust impl<C: RaftTypeConfig> RaftNetwork<C> for MyNetwork { fn append_entries(&self, rpc: AppendEntriesRequest<C>, option: RPCOption ) -> Result<_, RPCError<C::NodeId, C::Node, RaftError<C::NodeId>>> { if rpc.entries.len() > 10 { return Err(PayloadTooLarge::new_entries_hint(10).into()); } // ... } } ```
- Loading branch information
1 parent
9c04cb0
commit 961469c
Showing
9 changed files
with
428 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//! Defines config hint for replication RPC | ||
/// Temporary config hint for replication | ||
#[derive(Clone, Debug, Default)] | ||
pub(crate) struct ReplicationHint { | ||
n: u64, | ||
|
||
/// How many times this hint can be used. | ||
ttl: u64, | ||
} | ||
|
||
impl ReplicationHint { | ||
/// Create a new `ReplicationHint` | ||
pub(crate) fn new(n: u64, ttl: u64) -> Self { | ||
Self { n, ttl } | ||
} | ||
|
||
pub(crate) fn get(&mut self) -> Option<u64> { | ||
if self.ttl > 0 { | ||
self.ttl -= 1; | ||
Some(self.n) | ||
} else { | ||
None | ||
} | ||
} | ||
} |
Oops, something went wrong.