Skip to content

Commit 4c172a8

Browse files
committed
graph: Refactor Compat::new
1 parent 4c41a8b commit 4c172a8

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

graph/src/components/store.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use failure::Error;
22
use futures::stream::poll_fn;
33
use futures::{Async, Future, Poll, Stream};
4-
use futures03::compat::Compat;
54
use lazy_static::lazy_static;
65
use mockall::predicate::*;
76
use mockall::*;
@@ -578,7 +577,7 @@ where
578577
let mut pending_event: Option<StoreEvent> = None;
579578
let mut source = self.source.fuse();
580579
let mut had_err = false;
581-
let mut delay = Compat::new(tokio::time::delay_for(interval).map(Result::<_, ()>::Ok));
580+
let mut delay = tokio::time::delay_for(interval).unit_error().compat();
582581
let logger = logger.clone();
583582

584583
let source = Box::new(poll_fn(move || -> Poll<Option<StoreEvent>, ()> {
@@ -605,7 +604,7 @@ where
605604
// Timer errors are harmless. Treat them as if the timer had
606605
// become ready.
607606
Ok(Async::Ready(())) | Err(_) => {
608-
delay = Compat::new(tokio::time::delay_for(interval).map(Ok));
607+
delay = tokio::time::delay_for(interval).unit_error().compat();
609608
true
610609
}
611610
};

graph/src/util/futures.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ where
151151
F: Fn() -> R + Send,
152152
R: Future<Item = I, Error = E> + Send,
153153
{
154-
use futures03::compat::Compat;
155154
use futures03::future::TryFutureExt;
156155

157156
let operation_name = self.inner.operation_name;
@@ -170,12 +169,11 @@ where
170169
log_after,
171170
limit_opt,
172171
move || {
173-
Compat::new(
174-
try_it()
175-
.timeout(timeout)
176-
.map_err(|_| TimeoutError::Elapsed)
177-
.and_then(|res| futures03::future::ready(res.map_err(TimeoutError::Inner))),
178-
)
172+
try_it()
173+
.timeout(timeout)
174+
.map_err(|_| TimeoutError::Elapsed)
175+
.and_then(|res| futures03::future::ready(res.map_err(TimeoutError::Inner)))
176+
.compat()
179177
},
180178
)
181179
}

0 commit comments

Comments
 (0)