volo-thrift 0.12.5

Thrift RPC framework implementation of volo.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
#![allow(dead_code)]
//! These codes are originally copied from `hyper/client/pool.rs` with a lot of modifications.

mod make_transport;
mod started;

use std::{
    collections::{HashMap, HashSet, VecDeque},
    fmt::Debug,
    future::Future,
    hash::Hash,
    ops::{Deref, DerefMut},
    pin::Pin,
    sync::{Arc, Mutex, Weak},
    task::{Context, Poll},
};

use futures::{
    future::{self, Either},
    ready,
};
use linked_hash_map::LinkedHashMap;
pub use make_transport::PooledMakeTransport;
use motore::service::UnaryService;
use pilota::thrift::TransportException;
use pin_project::pin_project;
use started::Started as _;
use tokio::{
    sync::oneshot,
    time::{Duration, Instant, Interval, interval},
};
use volo::Unwrap;

pub trait Key: Eq + Hash + Clone + Debug + Unpin + Send + 'static {}

impl<T> Key for T where T: Eq + Hash + Clone + Debug + Unpin + Send + 'static {}

/// A marker to identify what version a pooled connection is.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Ver {
    PingPong,
    Multiplex,
}

pub trait Poolable: Sized {
    // check if the connection is opened
    fn reusable(&self) -> impl Future<Output = bool> + Send;

    /// Reserve this connection.
    ///
    /// Allows for HTTP/2, pipeline etc to return a shared reservation.
    fn reserve(self) -> Reservation<Self> {
        Reservation::Unique(self)
    }

    // put back into pool before check shareable
    fn can_share(&self) -> bool {
        false
    }

    /// Synchronous, non-consuming checkout for shared connections.
    ///
    /// Returns `Some(clone)` if the connection is reusable; `None` otherwise.
    /// This allows shared (multiplex) connections to be checked out while
    /// holding the pool lock, eliminating the race window where the idle pool
    /// appears empty to concurrent callers.
    fn try_checkout(&self) -> Option<Self> {
        None
    }
}

/// When checking out a pooled connection, it might be that the connection
/// only supports a single reservation, or it might be usable for many.
///
/// Specifically, HTTP/1 requires a unique reservation, but HTTP/2 can be
/// used for multiple requests.
// FIXME: allow() required due to `impl Trait` leaking types to this lint
#[allow(missing_debug_implementations)]
pub enum Reservation<T> {
    /// This connection could be used multiple times, the first one will be
    /// reinserted into the `idle` pool, and the second will be given to
    /// the `waiter`.
    Shared(T, T),
    /// This connection requires unique access. It will be returned after
    /// use is complete.
    Unique(T),
}

/// Connection Pool for reuse connections
pub struct Pool<K: Key, T: Poolable> {
    // share between threads
    inner: Arc<Mutex<Inner<K, T>>>,
}

impl<K: Key, T: Poolable> Clone for Pool<K, T> {
    fn clone(&self) -> Self {
        Pool {
            inner: self.inner.clone(),
        }
    }
}

#[derive(Clone, Debug)]
pub struct Config {
    max_idle_per_key: usize,
    timeout: Duration,
}

impl Default for Config {
    fn default() -> Self {
        Config {
            max_idle_per_key: 10240,
            timeout: Duration::from_secs(15),
        }
    }
}

impl Config {
    pub fn new(max_idle_per_key: usize, timeout: Duration) -> Self {
        Config {
            max_idle_per_key,
            timeout,
        }
    }

    pub fn max_idle_per_key(mut self, max_idle_per_key: usize) -> Self {
        self.max_idle_per_key = max_idle_per_key;
        self
    }

    pub fn timeout(mut self, timeout: Duration) -> Self {
        self.timeout = timeout;
        self
    }
}

// This is because `Weak::new()` *allocates* space for `T`, even if it
// doesn't need it!
struct WeakOpt<T>(Option<Weak<T>>);

impl<T> WeakOpt<T> {
    fn none() -> Self {
        WeakOpt(None)
    }

    fn downgrade(arc: &Arc<T>) -> Self {
        WeakOpt(Some(Arc::downgrade(arc)))
    }

    fn upgrade(&self) -> Option<Arc<T>> {
        self.0.as_ref().and_then(Weak::upgrade)
    }
}

struct Expiration(Option<Duration>);

impl Expiration {
    fn new(dur: Option<Duration>) -> Expiration {
        Expiration(dur)
    }

    fn expires(&self, instant: Instant) -> bool {
        match self.0 {
            // Avoid `Instant::elapsed` to avoid issues like rust-lang/rust#86470.
            Some(timeout) => Instant::now().saturating_duration_since(instant) > timeout,
            None => false,
        }
    }
}

impl<K: Key, T: Poolable + Send + 'static> Pool<K, T> {
    #[allow(dead_code)]
    pub fn new(cfg: Option<Config>) -> Self {
        let cfg = cfg.unwrap_or_default();
        let (tx, rx) = oneshot::channel();
        let inner = Arc::new(Mutex::new(Inner {
            connecting: HashSet::new(),
            idle: HashMap::new(),
            waiters: HashMap::new(),
            timeout: cfg.timeout,
            max_idle_per_key: cfg.max_idle_per_key,
            _pool_drop_rx: rx,
        }));

        let idle_task = IdleTask {
            interval: interval(cfg.timeout),
            inner: Arc::downgrade(&inner),
            pool_drop_tx: tx,
        };
        tokio::spawn(idle_task);
        Pool { inner }
    }

    /// Ensure that there is only ever 1 connecting task for Multiplex
    /// connections. This does nothing for PingPong.
    pub fn connecting(&self, key: &K, ver: Ver) -> Option<Connecting<K, T>> {
        if ver == Ver::Multiplex {
            let mut inner = self.inner.lock().unwrap();
            return if inner.connecting.insert(key.clone()) {
                let connecting = Connecting {
                    key: key.clone(),
                    pool: WeakOpt::downgrade(&self.inner),
                };
                tracing::trace!("Multiplex connecting for {:?}", key);
                Some(connecting)
            } else {
                tracing::trace!("Multiplex connecting already in progress for {:?}", key);
                None
            };
        }

        // else
        Some(Connecting {
            key: key.clone(),
            // in PingPong's case, there is never a lock, so we don't
            // need to do anything in Drop.
            pool: WeakOpt::none(),
        })
    }

    /// Returns a `Checkout` which is a future that resolves if an idle
    /// connection becomes available.
    pub fn checkout(&self, key: K, waiter: (oneshot::Receiver<T>, usize)) -> Checkout<K, T> {
        Checkout {
            key,
            pool: self.clone(),
            waiter,
            clean: true,
        }
    }

    pub async fn get<MT>(
        &self,
        key: K,
        ver: Ver,
        mt: MT,
    ) -> Result<Pooled<K, T>, crate::ClientError>
    where
        T: Poolable + Send + 'static,
        MT: UnaryService<K, Response = T> + Send + 'static + Sync,
        MT::Error: Into<crate::ClientError> + Send,
    {
        let (rx, waiter_token) = {
            let entry = 'outer: loop {
                let entry = 'inner: {
                    let mut inner = self.inner.lock().volo_unwrap();
                    // 1. check the idle and opened connections
                    let expiration = Expiration::new(Some(inner.timeout));

                    if let Some(list) = inner.idle.get_mut(&key) {
                        tracing::trace!("[VOLO] take? {:?}: expiration = {:?}", key, expiration.0);

                        // Fast path: shared (multiplex) connections can be checked out
                        // synchronously while holding the lock. This avoids the race where
                        // the idle pool appears empty after pop, causing spurious new
                        // connections.
                        while list.front().is_some_and(|e| e.inner.can_share()) {
                            if expiration.expires(list[0].idle_at) {
                                list.pop_front();
                                continue;
                            }
                            if let Some(conn) = list[0].inner.try_checkout() {
                                list[0].idle_at = Instant::now();
                                return Ok(self.reuse(&key, conn));
                            }
                            // try_checkout returned None: either not implemented or
                            // connection is broken. Fall through to the slow path
                            // which will do the full async reusable() check.
                            break;
                        }

                        while let Some(entry) = list.pop_front() {
                            // TODO: Actually, since the `idle` list is pushed to the end always,
                            // that would imply that if *this* entry is expired, then anything
                            // "earlier" in the list would *have* to be expired also... Right?
                            //
                            // In that case, we could just break out of the loop and drop the
                            // whole list...
                            if expiration.expires(entry.idle_at) {
                                tracing::trace!("[VOLO] removing expired connection for {:?}", key);
                                continue;
                            }
                            break 'inner entry;
                        }
                        break 'outer None;
                    } else {
                        break 'outer None;
                    }
                };
                // If the connection has been closed, or is older than our idle
                // timeout, simply drop it and keep looking...
                if !entry.inner.reusable().await {
                    continue;
                }
                break 'outer Some(entry);
            };

            let mut inner = self.inner.lock().volo_unwrap();

            if let Some(t) = entry {
                let value = match t.inner.reserve() {
                    Reservation::Shared(to_reinsert, to_return) => {
                        if let Some(list) = inner.idle.get_mut(&key) {
                            list.push_back(Idle {
                                idle_at: Instant::now(),
                                inner: to_reinsert,
                            })
                        }
                        to_return
                    }
                    Reservation::Unique(unique) => unique,
                };
                return Ok(self.reuse(&key, value));
            }
            // 2. no valid idle then add caller into waiters and make connection
            let waiters = if let Some(waiter) = inner.waiters.get_mut(&key) {
                waiter
            } else {
                inner
                    .waiters
                    .entry(key.clone())
                    .or_insert_with(Default::default)
            };
            let (tx, rx) = oneshot::channel();
            (rx, waiters.insert(tx))
            // drop lock guard before await
        };

        // 3. select waiter and mc return future
        let checkout = self.checkout(key.clone(), (rx, waiter_token));
        let connector = {
            let key = key.clone();
            let this = self.clone();
            move || {
                Box::pin(async move {
                    match this.connecting(&key, ver) {
                        Some(connecting) => match mt.call(key).await {
                            Ok(t) => {
                                tracing::debug!(
                                    "[VOLO] make_transport finished for {:?}",
                                    &connecting.key
                                );
                                Ok(this.pooled(connecting, t))
                            }
                            Err(e) => Err(e),
                        },
                        None => future::pending().await,
                    }
                })
            }
        };

        // waiter or make transport finished
        match future::select(checkout, started::lazy(connector)).await {
            Either::Left((Ok(v), fut)) => {
                // check the make transport future has started
                if fut.started() {
                    // complete the make transport and put into pool
                    tokio::spawn(fut);
                }
                // get connection from pool
                Ok(self.reuse(&key, v))
            }
            Either::Right((Ok(v), _)) => {
                tracing::debug!("[VOLO] get connection from pool for {:?}", key);
                Ok(v)
            }
            // means connection pool is dropped
            Either::Left((Err(e), _)) => {
                tracing::error!("[VOLO] wait a idle connection error: {:?}", e);
                Err(TransportException::from(std::io::Error::other(format!(
                    "wait a idle connection error: {e:?}"
                )))
                .into())
            }
            // maybe there is no more connection put back into pool and waiter will block forever,
            // so just return error
            Either::Right((Err(e), _)) => {
                let e = e.into();
                tracing::error!("[VOLO] create connection error: {:?}, key: {:?}", e, key);
                Err(e)
            }
        }
    }

    fn pooled(&self, mut connecting: Connecting<K, T>, value: T) -> Pooled<K, T> {
        let (value, pool_ref) = {
            match value.reserve() {
                Reservation::Shared(to_insert, to_return) => {
                    let mut inner = self.inner.lock().unwrap();
                    inner.put(connecting.key.clone(), to_insert);
                    inner.connected(&connecting.key);
                    connecting.pool = WeakOpt::none();
                    // Shared reservations don't need a reference to the pool,
                    // since the pool always keeps a copy.
                    (to_return, None)
                }
                Reservation::Unique(value) => {
                    // Unique reservations must take a reference to the pool
                    // since they hope to reinsert once the reservation is
                    // completed
                    (value, Some(Arc::downgrade(&self.inner)))
                }
            }
        };
        Pooled::new(connecting.key.clone(), value, WeakOpt(pool_ref))
    }

    fn reuse(&self, key: &K, value: T) -> Pooled<K, T> {
        tracing::debug!("[VOLO] reuse idle connection for {:?}", key);
        // TODO: unhack this
        // In Pool::pooled(), which is used for inserting brand new connections,
        // there's some code that adjusts the pool reference taken depending
        // on if the Reservation can be shared or is unique. By the time
        // reuse() is called, the reservation has already been made, and
        // we just have the final value, without knowledge of if this is
        // unique or shared.
        let mut pool_ref = None;
        if !value.can_share() {
            pool_ref = Some(Arc::downgrade(&self.inner));
        }
        Pooled::new(key.clone(), value, WeakOpt(pool_ref))
    }
}

pub struct Connecting<K: Key, T: Poolable> {
    key: K,
    pool: WeakOpt<Mutex<Inner<K, T>>>,
}

impl<K: Key, T> Connecting<K, T>
where
    T: Poolable + Send + 'static,
{
    pub fn multiplex(self, pool: &Pool<K, T>) -> Option<Self> {
        pool.connecting(&self.key, Ver::Multiplex)
    }
}

impl<K: Key, T: Poolable> Drop for Connecting<K, T> {
    fn drop(&mut self) {
        if let Some(pool) = self.pool.upgrade() {
            // No need to panic on drop, that could abort!
            if let Ok(mut inner) = pool.lock() {
                inner.connected(&self.key);
            }
        }
    }
}

pub struct Checkout<K: Key, T: Poolable> {
    key: K,
    pool: Pool<K, T>,
    waiter: (oneshot::Receiver<T>, usize),
    clean: bool,
}

impl<K: Key, T: Poolable> Future for Checkout<K, T> {
    type Output = Result<T, oneshot::error::RecvError>;

    fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
        match Pin::new(&mut self.waiter.0).poll(cx) {
            Poll::Ready(v) => {
                // Successfully received an idle connection, it means that the corresponding tx is
                // already popped from waiters, so no need to remove it again.
                self.clean = false;
                Poll::Ready(v)
            }
            Poll::Pending => Poll::Pending,
        }
    }
}

impl<K: Key, T: Poolable> Drop for Checkout<K, T> {
    fn drop(&mut self) {
        // if clean needed, remove the corresponding tx from waiters
        if self.clean {
            tracing::trace!("checkout dropped for {:?}", self.key);
            if let Ok(mut pool) = self.pool.inner.lock() {
                if let Some(waiters) = pool.waiters.get_mut(&self.key) {
                    waiters.remove(self.waiter.1);
                }
            }
        }
    }
}

struct Idle<T> {
    inner: T,
    idle_at: Instant,
}

#[pin_project]
pub struct Pooled<K: Key, T: Poolable> {
    key: Option<K>,
    #[pin]
    t: Option<T>,
    // shared transport no need pool ref
    pool: WeakOpt<Mutex<Inner<K, T>>>,
}

impl<K: Key, T: Poolable> Pooled<K, T> {
    fn new(key: K, t: T, pool: WeakOpt<Mutex<Inner<K, T>>>) -> Self {
        Pooled {
            key: Some(key),
            t: Some(t),
            pool,
        }
    }

    pub(crate) async fn reuse(mut self) {
        let inner = self.t.take().volo_unwrap();
        if !inner.reusable().await {
            // If we *already* know the connection is done here,
            // it shouldn't be re-inserted back into the pool.
            return;
        }
        // let pool = self.pool.clone();
        let key = self.key.take().volo_unwrap();
        if let WeakOpt(Some(pool)) = self.pool {
            if let Some(pool) = pool.upgrade() {
                if let Ok(mut pool) = pool.lock() {
                    pool.put(key, inner);
                }
            }
        }
    }
}

impl<K: Key, T: Poolable> AsRef<T> for Pooled<K, T> {
    fn as_ref(&self) -> &T {
        self.t.as_ref().expect("not dropped")
    }
}

impl<K: Key, T: Poolable> AsMut<T> for Pooled<K, T> {
    fn as_mut(&mut self) -> &mut T {
        self.t.as_mut().expect("not dropped")
    }
}

impl<K: Key, T: Poolable> Deref for Pooled<K, T> {
    type Target = T;
    fn deref(&self) -> &T {
        self.as_ref()
    }
}

impl<K: Key, T: Poolable> DerefMut for Pooled<K, T> {
    fn deref_mut(&mut self) -> &mut T {
        self.as_mut()
    }
}

struct WaiterList<T> {
    inner: LinkedHashMap<usize, oneshot::Sender<T>>,
    counter: usize,
}

impl<T> Default for WaiterList<T> {
    fn default() -> Self {
        Self {
            inner: Default::default(),
            counter: 0,
        }
    }
}

impl<T> WaiterList<T> {
    pub fn pop(&mut self) -> Option<oneshot::Sender<T>> {
        self.inner.pop_front().map(|(_, v)| v)
    }

    pub fn is_empty(&self) -> bool {
        self.inner.is_empty()
    }

    pub fn insert(&mut self, sender: oneshot::Sender<T>) -> usize {
        let index = self.counter;
        self.counter = self.counter.wrapping_add(1);
        self.inner.insert(index, sender);
        index
    }

    pub fn remove(&mut self, index: usize) -> Option<oneshot::Sender<T>> {
        self.inner.remove(&index)
    }
}

struct Inner<K: Key, T: Poolable> {
    // A flag that a connection is being established, and the connection
    // should be shared. This prevents making multiple Multiplex connections
    // to the same host.
    connecting: HashSet<K>,
    // idle queue
    idle: HashMap<K, VecDeque<Idle<T>>>,
    // waiters wait for idle transport
    waiters: HashMap<K, WaiterList<T>>,
    // idle timeout and check interval
    timeout: Duration,
    // idle count per key
    max_idle_per_key: usize,
    // when rx dropped, then tx poll_closed will return Poll::Ready(())
    // then idle task exist
    _pool_drop_rx: oneshot::Receiver<()>,
}

impl<K: Key, T: Poolable> Inner<K, T> {
    // clear expired idle
    fn clear_expired(&mut self) {
        let timeout = self.timeout;
        let now = Instant::now();
        self.idle.retain(|key, values| {
            values.retain(|entry| {
                // if !entry.inner.reusable().await {
                //     continue;
                // }
                // TODO: check has_idle && remove the (idle, waiters) key
                if now - entry.idle_at > timeout {
                    tracing::trace!("[VOLO] idle interval evicting expired for {:?}", key);
                    return false;
                }

                true
            });
            !values.is_empty()
        });
    }
}

impl<K: Key, T: Poolable> Inner<K, T> {
    fn put(&mut self, key: K, t: T) {
        // check the wait queue
        let mut value = Some(t);
        if let Some(waiters) = self.waiters.get_mut(&key) {
            // find a waiter and send
            while let Some(waiter) = waiters.pop() {
                // check if waiter is dropped
                if !waiter.is_closed() {
                    let t = value.take().volo_unwrap();
                    let t = match t.reserve() {
                        Reservation::Shared(to_keep, to_send) => {
                            value = Some(to_keep);
                            to_send
                        }
                        Reservation::Unique(unique) => unique,
                    };
                    match waiter.send(t) {
                        Ok(()) => {
                            tracing::trace!("[VOLO] [pool put]: found waiter for {:?}", key);
                            if value.is_none() {
                                // Unique break
                                break;
                            }
                        }
                        Err(t) => {
                            value = Some(t);
                        }
                    }
                }
            }
            // if waiters is empty then remove from waiters
            if waiters.is_empty() {
                self.waiters.remove(&key);
            }
        }

        // check if send to some waiter
        if let Some(t) = value {
            if t.can_share() && self.idle.contains_key(&key) {
                tracing::trace!(
                    "[VOLO] put; existing idle Shareable connection for {:?}",
                    key
                );
                return;
            }
            // means doesn't send success
            // then put back to idle list
            let idle = self.idle.entry(key).or_default();
            if idle.len() < self.max_idle_per_key {
                idle.push_back(Idle {
                    inner: t,
                    idle_at: Instant::now(),
                });
            }
        }
    }

    /// A `Connecting` task is complete. Not necessarily successfully,
    /// but the lock is going away, so clean up.
    fn connected(&mut self, key: &K) {
        let existed = self.connecting.remove(key);
        debug_assert!(existed, "Connecting dropped, key not in pool.connecting");
        // cancel any waiters. if there are any, it's because
        // this Connecting task didn't complete successfully.
        // those waiters would never receive a connection.
        self.waiters.remove(key);
    }
}

// Idle refresh task
#[pin_project]
struct IdleTask<K: Key, T: Poolable> {
    // refresh interval
    #[pin]
    interval: Interval,
    // pool
    inner: Weak<Mutex<Inner<K, T>>>,
    // drop tx and rx recv error
    #[pin]
    pool_drop_tx: oneshot::Sender<()>,
}

impl<K: Key, T: Poolable> Future for IdleTask<K, T> {
    type Output = ();

    // long loop for check transport timeout
    fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
        let mut this = self.project();
        loop {
            match this.pool_drop_tx.as_mut().poll_closed(cx) {
                Poll::Ready(()) => {
                    tracing::trace!("[VOLO] pool closed, canceling idle interval");
                    return Poll::Ready(());
                }
                Poll::Pending => (),
            }
            ready!(this.interval.as_mut().poll_tick(cx));
            if let Some(inner) = this.inner.upgrade() {
                if let Ok(mut inner) = inner.lock() {
                    tracing::trace!("[VOLO] idle interval checking for expired");
                    inner.clear_expired();

                    continue;
                }
            }
            return Poll::Ready(());
        }
    }
}