remove bounds

This commit is contained in:
nora 2022-09-15 22:22:33 +02:00
parent ca3a6684cb
commit 28b397587e
2 changed files with 2 additions and 56 deletions

View file

@ -1,4 +1,3 @@
use crate::load::Load;
use crate::MakeService; use crate::MakeService;
use crate::Service; use crate::Service;
use crate::{Change, Discover}; use crate::{Change, Discover};
@ -31,8 +30,7 @@ where
D: Discover + Unpin, D: Discover + Unpin,
D::Key: Hash + Clone, D::Key: Hash + Clone,
D::Error: Into<crate::BoxError>, D::Error: Into<crate::BoxError>,
D::Service: Service<Req> + Load, D::Service: Service<Req>,
<D::Service as Load>::Metric: std::fmt::Debug,
<D::Service as Service<Req>>::Error: Into<crate::BoxError>, <D::Service as Service<Req>>::Error: Into<crate::BoxError>,
{ {
type Response = <D::Service as Service<Req>>::Response; type Response = <D::Service as Service<Req>>::Response;
@ -54,7 +52,7 @@ impl<MS, Target, Request> Stream for PoolDiscoverer<MS, Target, Request>
where where
MS: MakeService<Target, Request>, MS: MakeService<Target, Request>,
{ {
type Item = Result<Change<usize, DropNotifyService<MS::Service>>, MS::MakeError>; type Item = Result<Change<usize, DropNotifyService<MS::Service>>, MS::Error>;
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
todo!() todo!()
@ -67,9 +65,6 @@ impl Builder {
pub fn build<MS, Target, Request>() -> () pub fn build<MS, Target, Request>() -> ()
where where
MS: MakeService<Target, Request>, MS: MakeService<Target, Request>,
MS::Service: Load,
<MS::Service as Load>::Metric: std::fmt::Debug,
MS::MakeError: Into<crate::BoxError>,
MS::Error: Into<crate::BoxError>, MS::Error: Into<crate::BoxError>,
{ {
let d: PoolDiscoverer<MS, Target, Request> = todo!(); let d: PoolDiscoverer<MS, Target, Request> = todo!();
@ -90,11 +85,7 @@ type PinBalance<S, Request> = Balance<Pin<Box<S>>, Request>;
impl<MS, Target, Req> Service<Req> for Pool<MS, Target, Req> impl<MS, Target, Req> Service<Req> for Pool<MS, Target, Req>
where where
MS: MakeService<Target, Req>, MS: MakeService<Target, Req>,
MS::Service: Load,
<MS::Service as Load>::Metric: std::fmt::Debug,
MS::MakeError: Into<crate::BoxError>,
MS::Error: Into<crate::BoxError>, MS::Error: Into<crate::BoxError>,
Target: Clone,
{ {
type Response = <PinBalance<PoolDiscoverer<MS, Target, Req>, Req> as Service<Req>>::Response; type Response = <PinBalance<PoolDiscoverer<MS, Target, Req>, Req> as Service<Req>>::Response;
type Error = <PinBalance<PoolDiscoverer<MS, Target, Req>, Req> as Service<Req>>::Error; type Error = <PinBalance<PoolDiscoverer<MS, Target, Req>, Req> as Service<Req>>::Error;
@ -105,14 +96,6 @@ pub struct DropNotifyService<Svc> {
svc: Svc, svc: Svc,
} }
impl<Svc: Load> Load for DropNotifyService<Svc> {
type Metric = Svc::Metric;
fn load(&self) -> Self::Metric {
todo!()
}
}
impl<Request, Svc: Service<Request>> Service<Request> for DropNotifyService<Svc> { impl<Request, Svc: Service<Request>> Service<Request> for DropNotifyService<Svc> {
type Response = Svc::Response; type Response = Svc::Response;
type Future = Svc::Future; type Future = Svc::Future;

View file

@ -1,32 +1,15 @@
pub mod balance; pub mod balance;
use futures_core::TryStream; use futures_core::TryStream;
use std::future::Future;
pub trait Sealed<T> {}
/// Alias for a type-erased error type.
pub type BoxError = Box<dyn std::error::Error + Send + Sync>; pub type BoxError = Box<dyn std::error::Error + Send + Sync>;
mod load {
pub trait Load {
type Metric;
fn load(&self) -> Self::Metric;
}
}
pub trait Discover { pub trait Discover {
type Key; type Key;
type Service; type Service;
type Error; type Error;
} }
impl<K, S, E, D: ?Sized> Sealed<Change<(), ()>> for D
where
D: TryStream<Ok = Change<K, S>, Error = E>,
K: Eq,
{
}
impl<K, S, E, D: ?Sized> Discover for D impl<K, S, E, D: ?Sized> Discover for D
where where
D: TryStream<Ok = Change<K, S>, Error = E>, D: TryStream<Ok = Change<K, S>, Error = E>,
@ -49,25 +32,5 @@ pub trait MakeService<Target, Request> {
type Response; type Response;
type Error; type Error;
type Service: Service<Request, Response = Self::Response, Error = Self::Error>; type Service: Service<Request, Response = Self::Response, Error = Self::Error>;
type MakeError;
type Future; type Future;
} }
impl<M, S, Target, Request> Sealed<(Target, Request)> for M
where
M: Service<Target, Response = S>,
S: Service<Request>,
{
}
impl<M, S, Target, Request> MakeService<Target, Request> for M
where
M: Service<Target, Response = S>,
S: Service<Request>,
{
type Response = S::Response;
type Error = S::Error;
type Service = S;
type MakeError = M::Error;
type Future = M::Future;
}