blob: 0778ad0017af66f64d6d92e60343d71c92bd8cf8 (
plain)
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
|
use super::handler::HandlerService;
use crate::config::Config;
use hyper::service::Service;
use nats::Connection;
use std::{
future::{ready, Ready},
sync::Arc,
task::{Context, Poll},
};
pub struct MakeSvc {
pub settings: Arc<Config>,
pub nats: Arc<Connection>,
}
impl<T> Service<T> for MakeSvc {
type Response = HandlerService;
type Error = std::io::Error;
type Future = Ready<Result<Self::Response, Self::Error>>;
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Ok(()).into()
}
fn call(&mut self, _: T) -> Self::Future {
ready(Ok(HandlerService {
config: self.settings.clone(),
nats: self.nats.clone(),
}))
}
}
|