Skip to content

Commit 1903566

Browse files
committed
wip: pool-expire
1 parent bbf005e commit 1903566

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/client/pool/expire.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//! todo
2+
3+
use std::task::{Context, Poll};
4+
use std::sync::{Arc, Mutex, Weak};
5+
6+
use tower_service::Service;
7+
8+
9+
/// todo
10+
pub struct Expire<S> {
11+
inner: Arc<Mutex<S>>,
12+
}
13+
14+
/// todo
15+
pub struct Handle<S> {
16+
inner: Weak<Mutex<S>>,
17+
}
18+
19+
// ===== impl Expire =====
20+
21+
impl<S, Req> Service<Req> for Expire<S>
22+
where
23+
S: Service<Req>,
24+
{
25+
type Response = S::Response;
26+
type Error = S::Error;
27+
type Future = S::Future;
28+
29+
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
30+
self.inner.lock().unwrap().poll_ready(cx)
31+
}
32+
33+
fn call(&mut self, req: Req) -> Self::Future {
34+
self.inner.lock().unwrap().call(req)
35+
}
36+
}
37+
38+
39+
// ===== impl Handle =====
40+
41+
impl<S> Handle<S> {
42+
pub async fn when<'a, F>(&self, fut: F) -> Option<impl std::ops::DerefMut<Target = S>>
43+
where
44+
F: std::future::Future<Output = ()>,
45+
{
46+
fut.await;
47+
//Some(self.inner.upgrade()?.lock().unwrap())
48+
todo!()
49+
}
50+
}

src/client/pool/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Composable pool services
22
33
pub mod cache;
4+
//pub mod expire;
45
pub mod map;
56
pub mod negotiate;
67
pub mod singleton;

0 commit comments

Comments
 (0)