|
1 |
| -use std::{sync::Arc, time::Duration}; |
2 | 1 | #[cfg(test)]
|
3 | 2 | use std::cmp::Ordering;
|
| 3 | +use std::{sync::Arc, time::Duration}; |
4 | 4 |
|
5 | 5 | use derivative::Derivative;
|
6 |
| -use serde::{Deserialize}; |
7 | 6 | #[cfg(test)]
|
8 | 7 | use serde::de::{Deserializer, Error};
|
| 8 | +use serde::Deserialize; |
9 | 9 | use typed_builder::TypedBuilder;
|
10 | 10 |
|
11 | 11 | use crate::{
|
@@ -46,7 +46,11 @@ pub(crate) struct ConnectionPoolOptions {
|
46 | 46 |
|
47 | 47 | /// Interval between background thread maintenance runs (e.g. ensure minPoolSize).
|
48 | 48 | #[cfg(test)]
|
49 |
| - #[serde(default, rename = "backgroundThreadIntervalMS", deserialize_with = "BackgroundThreadInterval::deserialize_from_i64_millis")] |
| 49 | + #[serde( |
| 50 | + default, |
| 51 | + rename = "backgroundThreadIntervalMS", |
| 52 | + deserialize_with = "BackgroundThreadInterval::deserialize_from_i64_millis" |
| 53 | + )] |
50 | 54 | pub(crate) background_thread_interval: Option<BackgroundThreadInterval>,
|
51 | 55 |
|
52 | 56 | /// Connections that have been ready for usage in the pool for longer than `max_idle_time` will
|
@@ -136,11 +140,17 @@ impl BackgroundThreadInterval {
|
136 | 140 | D: Deserializer<'de>,
|
137 | 141 | {
|
138 | 142 | let millis = Option::<i64>::deserialize(deserializer)?;
|
139 |
| - let millis = if let Some(m) = millis { m } else { return Ok(None) }; |
| 143 | + let millis = if let Some(m) = millis { |
| 144 | + m |
| 145 | + } else { |
| 146 | + return Ok(None); |
| 147 | + }; |
140 | 148 | Ok(Some(match millis.cmp(&0) {
|
141 | 149 | Ordering::Less => BackgroundThreadInterval::Never,
|
142 | 150 | Ordering::Equal => return Err(D::Error::custom("zero is not allowed")),
|
143 |
| - Ordering::Greater => BackgroundThreadInterval::Every(Duration::from_millis(millis as u64)), |
| 151 | + Ordering::Greater => { |
| 152 | + BackgroundThreadInterval::Every(Duration::from_millis(millis as u64)) |
| 153 | + } |
144 | 154 | }))
|
145 | 155 | }
|
146 | 156 | }
|
|
0 commit comments