feat(client): Reject empty open_timeouts configuration with dedicated error
This commit is contained in:
3 files changed
+17
No files matched your search
@@ -791,4 +791,16 @@ mod tests {
|
|||||||
Err(ClientError::OpenTimeoutTooSmall { .. })
|
Err(ClientError::OpenTimeoutTooSmall { .. })
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn empty_open_timeouts_is_rejected() {
|
||||||
|
let config = ClientConfig {
|
||||||
|
open_timeouts: vec![],
|
||||||
|
..ClientConfig::default()
|
||||||
|
};
|
||||||
|
assert!(matches!(
|
||||||
|
Client::connect(config),
|
||||||
|
Err(ClientError::NoOpenTimeouts)
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,8 @@ pub enum ClientError {
|
|||||||
timeout: Duration,
|
timeout: Duration,
|
||||||
minimum: Duration,
|
minimum: Duration,
|
||||||
},
|
},
|
||||||
|
#[error("open_timeouts must not be empty")]
|
||||||
|
NoOpenTimeouts,
|
||||||
#[error("server rejected the open request")]
|
#[error("server rejected the open request")]
|
||||||
ServerRejected,
|
ServerRejected,
|
||||||
#[error("unexpected no-test open reply")]
|
#[error("unexpected no-test open reply")]
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub(crate) fn validate_open_timeouts(timeouts: &[Duration]) -> Result<(), ClientError> {
|
pub(crate) fn validate_open_timeouts(timeouts: &[Duration]) -> Result<(), ClientError> {
|
||||||
|
if timeouts.is_empty() {
|
||||||
|
return Err(ClientError::NoOpenTimeouts);
|
||||||
|
}
|
||||||
for timeout in timeouts {
|
for timeout in timeouts {
|
||||||
if *timeout < MIN_OPEN_TIMEOUT {
|
if *timeout < MIN_OPEN_TIMEOUT {
|
||||||
return Err(ClientError::OpenTimeoutTooSmall {
|
return Err(ClientError::OpenTimeoutTooSmall {
|
||||||
|
|||||||
Reference in new issue
Block a user