use crate::{extension, extension::registry_extension::proxy::RegistryProxy, StdError, Url};
use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
};
use tower_service::Service;
pub mod integration;
pub mod protocol;
pub mod registry;
#[derive(Clone)]
pub struct MkRegistryService {
registry_url: Url,
}
impl MkRegistryService {
pub fn new(registry_url: Url) -> Self {
Self { registry_url }
}
}
impl Service<()> for MkRegistryService {
type Response = RegistryProxy;
type Error = StdError;
type Future =
Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send + 'static>>;
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, _req: ()) -> Self::Future {
let fut = extension::EXTENSIONS.load_registry(self.registry_url.clone());
Box::pin(fut)
}
}