Struct openraft::error::PayloadTooLarge
source · pub struct PayloadTooLarge { /* private fields */ }
Expand description
Error indicating that an RPC is too large and cannot be sent.
This is a retryable error:
A RaftNetwork
implementation returns this error to inform Openraft to divide an
AppendEntriesRequest
into smaller chunks.
Openraft will immediately retry sending in smaller chunks.
If the request cannot be divided(contains only one entry), Openraft interprets it as
Unreachable
.
A hint can be provided to help Openraft in splitting the request.
The application should also set an appropriate value for Config::max_payload_entries
to
avoid returning this error if possible.
Example:
ⓘ
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());
}
// ...
}
}
Implementations§
source§impl PayloadTooLarge
impl PayloadTooLarge
sourcepub fn new_entries_hint(entries_hint: u64) -> Self
pub fn new_entries_hint(entries_hint: u64) -> Self
Create a new PayloadTooLarge, with entries hint, without the causing error.
sourcepub fn with_source_error(self, e: &(impl Error + 'static)) -> Self
pub fn with_source_error(self, e: &(impl Error + 'static)) -> Self
Set the source error that causes this PayloadTooLarge error.
pub fn action(&self) -> RPCTypes
sourcepub fn entries_hint(&self) -> u64
pub fn entries_hint(&self) -> u64
Get the hint for entries number.
Trait Implementations§
source§impl Clone for PayloadTooLarge
impl Clone for PayloadTooLarge
source§fn clone(&self) -> PayloadTooLarge
fn clone(&self) -> PayloadTooLarge
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for PayloadTooLarge
impl Debug for PayloadTooLarge
source§impl<'de> Deserialize<'de> for PayloadTooLarge
impl<'de> Deserialize<'de> for PayloadTooLarge
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>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for PayloadTooLarge
impl Display for PayloadTooLarge
source§impl Error for PayloadTooLarge
impl Error for PayloadTooLarge
source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
source§impl<NID: NodeId, N: Node, E: Error> From<PayloadTooLarge> for RPCError<NID, N, E>
impl<NID: NodeId, N: Node, E: Error> From<PayloadTooLarge> for RPCError<NID, N, E>
source§fn from(source: PayloadTooLarge) -> Self
fn from(source: PayloadTooLarge) -> Self
Converts to this type from the input type.
source§impl PartialEq for PayloadTooLarge
impl PartialEq for PayloadTooLarge
source§fn eq(&self, other: &PayloadTooLarge) -> bool
fn eq(&self, other: &PayloadTooLarge) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for PayloadTooLarge
impl Serialize for PayloadTooLarge
impl Eq for PayloadTooLarge
impl StructuralPartialEq for PayloadTooLarge
Auto Trait Implementations§
impl Freeze for PayloadTooLarge
impl RefUnwindSafe for PayloadTooLarge
impl Send for PayloadTooLarge
impl Sync for PayloadTooLarge
impl Unpin for PayloadTooLarge
impl UnwindSafe for PayloadTooLarge
Blanket Implementations§
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
Mutably borrows from an owned value. Read more