Created
October 18, 2018 20:40
-
-
Save pjenvey/7fd511843bd218dfd990d513bf5fc737 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use db::{Db, DbFuture, DbPool}; | |
impl DbPool for MysqlDbPool { | |
//type Db = MysqlDb; | |
//fn get(&self) -> DbFuture<Self::Db> { | |
fn get(&self) -> DbFuture<Box<Db>> { | |
// XXX: | |
use futures::future::poll_fn; | |
use futures::Future; | |
use tokio_threadpool::blocking; | |
let s = self.clone(); | |
Box::new( | |
poll_fn(move || { | |
blocking(|| s.get_sync().map(|db| Box::new(db) as Box<Db>)) | |
.map_err(|_| panic!("Database queries must be run inside a Tokio thread pool!")) | |
}).and_then(|r| r), | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment