diff --git a/monolake-core/src/config/mod.rs b/monolake-core/src/config/mod.rs index 5416b9b..4be3d82 100644 --- a/monolake-core/src/config/mod.rs +++ b/monolake-core/src/config/mod.rs @@ -16,7 +16,7 @@ use serde::{Deserialize, Serialize}; // Default iouring/epoll entries: 32k const DEFAULT_ENTRIES: u32 = 32768; -pub const FALLBACK_PARALLELISM: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(1) }; +pub const FALLBACK_PARALLELISM: NonZeroUsize = NonZeroUsize::new(1).unwrap(); /// Configuration structure for a service, combining listener and server configs. /// diff --git a/monolake-services/Cargo.toml b/monolake-services/Cargo.toml index 7e1f5c1..51a1953 100644 --- a/monolake-services/Cargo.toml +++ b/monolake-services/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "monolake-services" version = "0.3.2" +edition = "2024" description = "MonoLake Services Implementation" authors.workspace = true categories.workspace = true -edition.workspace = true keywords.workspace = true license.workspace = true repository.workspace = true diff --git a/monolake-services/src/common/cancel/mod.rs b/monolake-services/src/common/cancel/mod.rs index 26e9b2a..2d577de 100644 --- a/monolake-services/src/common/cancel/mod.rs +++ b/monolake-services/src/common/cancel/mod.rs @@ -47,8 +47,7 @@ impl Canceller { let handler = unsafe { &mut *self.handler.get() }; if !handler.cancelled { handler.cancelled = true; - let waiters: LinkedList = - std::mem::replace(&mut handler.waiters, LinkedList::new()); + let waiters: LinkedList = std::mem::take(&mut handler.waiters); for waker in waiters.into_iter() { waker.wake(); } @@ -121,12 +120,12 @@ impl Future for Waiter { impl Drop for Waiter { fn drop(&mut self) { - if let Some(index) = unsafe { *self.index.get() } { - if let Some(handler) = self.handler.upgrade() { - let handler = unsafe { &mut *handler.get() }; - if !handler.cancelled { - handler.waiters.remove(index); - } + if let Some(index) = unsafe { *self.index.get() } + && let Some(handler) = self.handler.upgrade() + { + let handler = unsafe { &mut *handler.get() }; + if !handler.cancelled { + handler.waiters.remove(index); } } } diff --git a/monolake-services/src/common/context.rs b/monolake-services/src/common/context.rs index 4decd5f..773e964 100644 --- a/monolake-services/src/common/context.rs +++ b/monolake-services/src/common/context.rs @@ -43,8 +43,8 @@ use std::marker::PhantomData; use certain_map::Handler; use monolake_core::{context::PeerAddr, listener::AcceptedAddr}; use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, ParamSet, Service, + layer::{FactoryLayer, layer_fn}, }; /// A service to insert Context into the request processing pipeline, compatible with `certain_map`. @@ -81,10 +81,10 @@ where // directly(here `Transformed` is not bound but `Response` and `Error` are). for<'a> CXStore::Hdr<'a>: ParamSet, for<'a> T: Service< - (R, as ParamSet>::Transformed), - Response = Resp, - Error = Err, - >, + (R, as ParamSet>::Transformed), + Response = Resp, + Error = Err, + >, { type Response = Resp; type Error = Err; @@ -113,10 +113,7 @@ impl MakeService for ContextService { fn make_via_ref(&self, old: Option<&Self::Service>) -> Result { Ok(ContextService { ctx: PhantomData, - inner: self - .inner - .make_via_ref(old.map(|o| &o.inner)) - .map_err(Into::into)?, + inner: self.inner.make_via_ref(old.map(|o| &o.inner))?, }) } } @@ -131,11 +128,7 @@ impl AsyncMakeService for ContextService Result { Ok(ContextService { ctx: PhantomData, - inner: self - .inner - .make_via_ref(old.map(|o| &o.inner)) - .await - .map_err(Into::into)?, + inner: self.inner.make_via_ref(old.map(|o| &o.inner)).await?, }) } } diff --git a/monolake-services/src/common/delay.rs b/monolake-services/src/common/delay.rs index a83b574..1213d84 100644 --- a/monolake-services/src/common/delay.rs +++ b/monolake-services/src/common/delay.rs @@ -1,8 +1,8 @@ use std::time::Duration; use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, Param, Service, + layer::{FactoryLayer, layer_fn}, }; #[derive(Clone)] @@ -46,10 +46,7 @@ impl MakeService for DelayService { fn make_via_ref(&self, old: Option<&Self::Service>) -> Result { Ok(DelayService { delay: self.delay, - inner: self - .inner - .make_via_ref(old.map(|o| &o.inner)) - .map_err(Into::into)?, + inner: self.inner.make_via_ref(old.map(|o| &o.inner))?, }) } } @@ -64,11 +61,7 @@ impl AsyncMakeService for DelayService { ) -> Result { Ok(DelayService { delay: self.delay, - inner: self - .inner - .make_via_ref(old.map(|o| &o.inner)) - .await - .map_err(Into::into)?, + inner: self.inner.make_via_ref(old.map(|o| &o.inner)).await?, }) } } diff --git a/monolake-services/src/common/erase.rs b/monolake-services/src/common/erase.rs index 5c47c55..d12e3ce 100644 --- a/monolake-services/src/common/erase.rs +++ b/monolake-services/src/common/erase.rs @@ -1,6 +1,6 @@ use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, Service, + layer::{FactoryLayer, layer_fn}, }; #[derive(Debug)] @@ -15,10 +15,7 @@ impl MakeService for EraseResp { #[inline] fn make_via_ref(&self, old: Option<&Self::Service>) -> Result { Ok(EraseResp { - svc: self - .svc - .make_via_ref(old.map(|o| &o.svc)) - .map_err(Into::into)?, + svc: self.svc.make_via_ref(old.map(|o| &o.svc))?, }) } } @@ -33,11 +30,7 @@ impl AsyncMakeService for EraseResp { old: Option<&Self::Service>, ) -> Result { Ok(EraseResp { - svc: self - .svc - .make_via_ref(old.map(|o| &o.svc)) - .await - .map_err(Into::into)?, + svc: self.svc.make_via_ref(old.map(|o| &o.svc)).await?, }) } } diff --git a/monolake-services/src/common/map.rs b/monolake-services/src/common/map.rs index 8aaf2a7..c9445d6 100644 --- a/monolake-services/src/common/map.rs +++ b/monolake-services/src/common/map.rs @@ -1,6 +1,6 @@ use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, Service, + layer::{FactoryLayer, layer_fn}, }; pub struct Map { @@ -90,11 +90,7 @@ impl AsyncMakeService for Map { old: Option<&Self::Service>, ) -> Result { Ok(Map { - inner: self - .inner - .make_via_ref(old.map(|o| &o.inner)) - .await - .map_err(Into::into)?, + inner: self.inner.make_via_ref(old.map(|o| &o.inner)).await?, rewrite_f: self.rewrite_f.clone(), }) } @@ -109,11 +105,7 @@ impl AsyncMakeService for MapErr { old: Option<&Self::Service>, ) -> Result { Ok(MapErr { - inner: self - .inner - .make_via_ref(old.map(|o| &o.inner)) - .await - .map_err(Into::into)?, + inner: self.inner.make_via_ref(old.map(|o| &o.inner)).await?, rewrite_f: self.rewrite_f.clone(), }) } @@ -128,11 +120,7 @@ impl AsyncMakeService for FnSvc { old: Option<&Self::Service>, ) -> Result { Ok(FnSvc { - inner: self - .inner - .make_via_ref(old.map(|o| &o.inner)) - .await - .map_err(Into::into)?, + inner: self.inner.make_via_ref(old.map(|o| &o.inner)).await?, rewrite_f: self.rewrite_f.clone(), }) } @@ -144,10 +132,7 @@ impl MakeService for Map { fn make_via_ref(&self, old: Option<&Self::Service>) -> Result { Ok(Map { - inner: self - .inner - .make_via_ref(old.map(|o| &o.inner)) - .map_err(Into::into)?, + inner: self.inner.make_via_ref(old.map(|o| &o.inner))?, rewrite_f: self.rewrite_f.clone(), }) } @@ -159,10 +144,7 @@ impl MakeService for MapErr { fn make_via_ref(&self, old: Option<&Self::Service>) -> Result { Ok(MapErr { - inner: self - .inner - .make_via_ref(old.map(|o| &o.inner)) - .map_err(Into::into)?, + inner: self.inner.make_via_ref(old.map(|o| &o.inner))?, rewrite_f: self.rewrite_f.clone(), }) } @@ -174,10 +156,7 @@ impl MakeService for FnSvc { fn make_via_ref(&self, old: Option<&Self::Service>) -> Result { Ok(FnSvc { - inner: self - .inner - .make_via_ref(old.map(|o| &o.inner)) - .map_err(Into::into)?, + inner: self.inner.make_via_ref(old.map(|o| &o.inner))?, rewrite_f: self.rewrite_f.clone(), }) } diff --git a/monolake-services/src/common/mod.rs b/monolake-services/src/common/mod.rs index 94138eb..4804e1b 100644 --- a/monolake-services/src/common/mod.rs +++ b/monolake-services/src/common/mod.rs @@ -10,7 +10,7 @@ pub mod selector; pub mod timeout; // TODO: remove following re-exports -pub use cancel::{linked_list, Canceller, CancellerDropper, Waiter}; +pub use cancel::{Canceller, CancellerDropper, Waiter, linked_list}; pub use context::ContextService; pub use delay::{Delay, DelayService}; pub use detect::{Detect, DetectService, FixedLengthDetector, PrefixDetector}; diff --git a/monolake-services/src/common/panic.rs b/monolake-services/src/common/panic.rs index b334285..78b29bd 100644 --- a/monolake-services/src/common/panic.rs +++ b/monolake-services/src/common/panic.rs @@ -59,8 +59,8 @@ use std::{fmt::Debug, panic::AssertUnwindSafe}; use futures::FutureExt; use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, Service, + layer::{FactoryLayer, layer_fn}, }; pub struct CatchPanicService { @@ -110,10 +110,7 @@ impl MakeService for CatchPanicService { fn make_via_ref(&self, old: Option<&Self::Service>) -> Result { Ok(CatchPanicService { - inner: self - .inner - .make_via_ref(old.map(|o| &o.inner)) - .map_err(Into::into)?, + inner: self.inner.make_via_ref(old.map(|o| &o.inner))?, }) } } @@ -127,11 +124,7 @@ impl AsyncMakeService for CatchPanicService { old: Option<&Self::Service>, ) -> Result { Ok(CatchPanicService { - inner: self - .inner - .make_via_ref(old.map(|o| &o.inner)) - .await - .map_err(Into::into)?, + inner: self.inner.make_via_ref(old.map(|o| &o.inner)).await?, }) } } diff --git a/monolake-services/src/common/timeout.rs b/monolake-services/src/common/timeout.rs index 325f9ff..b39f715 100644 --- a/monolake-services/src/common/timeout.rs +++ b/monolake-services/src/common/timeout.rs @@ -25,8 +25,8 @@ use std::time::Duration; use monoio::time::timeout; use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, Param, Service, + layer::{FactoryLayer, layer_fn}, }; /// Service that adds timeout functionality to an inner service. @@ -79,10 +79,7 @@ impl MakeService for TimeoutService { fn make_via_ref(&self, old: Option<&Self::Service>) -> Result { Ok(TimeoutService { timeout: self.timeout, - inner: self - .inner - .make_via_ref(old.map(|o| &o.inner)) - .map_err(Into::into)?, + inner: self.inner.make_via_ref(old.map(|o| &o.inner))?, }) } } @@ -97,11 +94,7 @@ impl AsyncMakeService for TimeoutService { ) -> Result { Ok(TimeoutService { timeout: self.timeout, - inner: self - .inner - .make_via_ref(old.map(|o| &o.inner)) - .await - .map_err(Into::into)?, + inner: self.inner.make_via_ref(old.map(|o| &o.inner)).await?, }) } } diff --git a/monolake-services/src/http/core.rs b/monolake-services/src/http/core.rs index b913937..58bd40f 100644 --- a/monolake-services/src/http/core.rs +++ b/monolake-services/src/http/core.rs @@ -67,9 +67,9 @@ use std::{convert::Infallible, fmt::Debug, time::Duration}; use bytes::Bytes; use certain_map::{Attach, Fork}; -use futures::{stream::FuturesUnordered, StreamExt}; +use futures::{StreamExt, stream::FuturesUnordered}; use http::StatusCode; -use monoio::io::{sink::SinkExt, stream::Stream, AsyncReadRent, AsyncWriteRent, Split, Splitable}; +use monoio::io::{AsyncReadRent, AsyncWriteRent, Split, Splitable, sink::SinkExt, stream::Stream}; use monoio_http::{ common::{ body::{Body, HttpBody, StreamHint}, @@ -82,13 +82,13 @@ use monoio_http::{ h2::server::SendResponse, }; use monolake_core::{ + AnyError, context::PeerAddr, http::{HttpAccept, HttpHandler}, - AnyError, }; use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, Param, ParamRef, Service, + layer::{FactoryLayer, layer_fn}, }; use tracing::{error, info, warn}; @@ -121,11 +121,11 @@ impl HttpCoreService { CXStore: 'static, for<'a> CXState: Attach, for<'a> H: HttpHandler< - >::Hdr<'a>, - HttpBody, - Body = HttpBody, - Error = Err, - >, + >::Hdr<'a>, + HttpBody, + Body = HttpBody, + Error = Err, + >, Err: Into + Debug, S: Split + AsyncReadRent + AsyncWriteRent, { @@ -283,11 +283,11 @@ impl HttpCoreService { CXStore: 'static, for<'a> CXState: Attach, for<'a> H: HttpHandler< - >::Hdr<'a>, - HttpBody, - Body = HttpBody, - Error = Err, - >, + >::Hdr<'a>, + HttpBody, + Body = HttpBody, + Error = Err, + >, Err: Into + Debug, S: Split + AsyncReadRent + AsyncWriteRent + Unpin + 'static, { diff --git a/monolake-services/src/http/detect.rs b/monolake-services/src/http/detect.rs index 8af5e20..8ddc1c8 100644 --- a/monolake-services/src/http/detect.rs +++ b/monolake-services/src/http/detect.rs @@ -41,8 +41,8 @@ //! - Implements zero-copy techniques where possible to reduce memory overhead use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, + layer::{FactoryLayer, layer_fn}, }; use crate::common::{DetectService, PrefixDetector}; diff --git a/monolake-services/src/http/handlers/connection_persistence.rs b/monolake-services/src/http/handlers/connection_persistence.rs index a89c730..e24d61c 100644 --- a/monolake-services/src/http/handlers/connection_persistence.rs +++ b/monolake-services/src/http/handlers/connection_persistence.rs @@ -24,16 +24,16 @@ //! use monolake_services::{ //! common::ContextService, //! http::{ +//! HttpServerTimeout, //! core::HttpCoreService, //! detect::H2Detect, //! handlers::{ -//! route::RouteConfig, ConnectionReuseHandler, ContentHandler, RewriteAndRouteHandler, -//! UpstreamHandler, +//! ConnectionReuseHandler, ContentHandler, RewriteAndRouteHandler, UpstreamHandler, +//! route::RouteConfig, //! }, -//! HttpServerTimeout, //! }, //! }; -//! use service_async::{layer::FactoryLayer, stack::FactoryStack, Param}; +//! use service_async::{Param, layer::FactoryLayer, stack::FactoryStack}; //! //! // Dummy struct to satisfy Param trait requirements //! struct DummyConfig; @@ -72,8 +72,8 @@ use http::{Request, Version}; use monolake_core::http::{HttpHandler, ResponseWithContinue}; use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, Service, + layer::{FactoryLayer, layer_fn}, }; use tracing::debug; diff --git a/monolake-services/src/http/handlers/content_handler.rs b/monolake-services/src/http/handlers/content_handler.rs index 919afa6..6734879 100644 --- a/monolake-services/src/http/handlers/content_handler.rs +++ b/monolake-services/src/http/handlers/content_handler.rs @@ -24,16 +24,16 @@ //! use monolake_services::{ //! common::ContextService, //! http::{ +//! HttpServerTimeout, //! core::HttpCoreService, //! detect::H2Detect, //! handlers::{ -//! route::RouteConfig, ConnectionReuseHandler, ContentHandler, RewriteAndRouteHandler, -//! UpstreamHandler, +//! ConnectionReuseHandler, ContentHandler, RewriteAndRouteHandler, UpstreamHandler, +//! route::RouteConfig, //! }, -//! HttpServerTimeout, //! }, //! }; -//! use service_async::{layer::FactoryLayer, stack::FactoryStack, Param}; +//! use service_async::{Param, layer::FactoryLayer, stack::FactoryStack}; //! //! // Dummy struct to satisfy Param trait requirements //! struct DummyConfig; @@ -82,8 +82,8 @@ use monoio_http::common::{ }; use monolake_core::http::{HttpHandler, ResponseWithContinue}; use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, Service, + layer::{FactoryLayer, layer_fn}, }; use crate::http::generate_response; diff --git a/monolake-services/src/http/handlers/mod.rs b/monolake-services/src/http/handlers/mod.rs index 9e6a6fd..cd638e2 100644 --- a/monolake-services/src/http/handlers/mod.rs +++ b/monolake-services/src/http/handlers/mod.rs @@ -60,16 +60,16 @@ //! use monolake_services::{ //! common::ContextService, //! http::{ +//! HttpServerTimeout, //! core::HttpCoreService, //! detect::H2Detect, //! handlers::{ -//! route::RouteConfig, ConnectionReuseHandler, ContentHandler, RewriteAndRouteHandler, -//! UpstreamHandler, +//! ConnectionReuseHandler, ContentHandler, RewriteAndRouteHandler, UpstreamHandler, +//! route::RouteConfig, //! }, -//! HttpServerTimeout, //! }, //! }; -//! use service_async::{layer::FactoryLayer, stack::FactoryStack, Param}; +//! use service_async::{Param, layer::FactoryLayer, stack::FactoryStack}; //! //! // Dummy struct to satisfy Param trait requirements //! struct DummyConfig; diff --git a/monolake-services/src/http/handlers/openid.rs b/monolake-services/src/http/handlers/openid.rs index 5701c03..bc02ef1 100644 --- a/monolake-services/src/http/handlers/openid.rs +++ b/monolake-services/src/http/handlers/openid.rs @@ -31,8 +31,8 @@ use openidconnect::{ use openidconnect::{HttpRequest, HttpResponse}; use serde::{Deserialize, Serialize}; use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, Param, Service, + layer::{FactoryLayer, layer_fn}, }; use thiserror::Error; use tracing::debug; diff --git a/monolake-services/src/http/handlers/route.rs b/monolake-services/src/http/handlers/route.rs index c980c7b..9cb81c2 100644 --- a/monolake-services/src/http/handlers/route.rs +++ b/monolake-services/src/http/handlers/route.rs @@ -31,16 +31,16 @@ //! use monolake_services::{ //! common::ContextService, //! http::{ +//! HttpServerTimeout, //! core::HttpCoreService, //! detect::H2Detect, //! handlers::{ -//! route::RouteConfig, ConnectionReuseHandler, ContentHandler, RewriteAndRouteHandler, -//! UpstreamHandler, +//! ConnectionReuseHandler, ContentHandler, RewriteAndRouteHandler, UpstreamHandler, +//! route::RouteConfig, //! }, -//! HttpServerTimeout, //! }, //! }; -//! use service_async::{layer::FactoryLayer, stack::FactoryStack, Param}; +//! use service_async::{Param, layer::FactoryLayer, stack::FactoryStack}; //! //! // Dummy struct to satisfy Param trait requirements //! struct DummyConfig; @@ -97,17 +97,17 @@ //! - Support for more advanced routing patterns (e.g., regex-based routing). //! - Enhanced metrics and logging for better observability. //! - Integration with service discovery systems for dynamic upstream management. -use http::{uri::Scheme, HeaderValue, Request, Response, StatusCode}; +use http::{HeaderValue, Request, Response, StatusCode, uri::Scheme}; use monoio_http::common::body::FixedBody; use monolake_core::{ + AnyError, http::{HttpError, HttpFatalError, HttpHandler, ResponseWithContinue}, util::uri_serde, - AnyError, }; use serde::{Deserialize, Serialize}; use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, Param, Service, + layer::{FactoryLayer, layer_fn}, }; use crate::{ diff --git a/monolake-services/src/http/handlers/upstream.rs b/monolake-services/src/http/handlers/upstream.rs index 5497cec..2328646 100644 --- a/monolake-services/src/http/handlers/upstream.rs +++ b/monolake-services/src/http/handlers/upstream.rs @@ -53,7 +53,7 @@ use std::{ }; use bytes::Bytes; -use http::{header, HeaderMap, HeaderValue, Request, StatusCode}; +use http::{HeaderMap, HeaderValue, Request, StatusCode, header}; use monoio::net::TcpStream; use monoio_http::common::{ body::{Body, HttpBody}, @@ -73,7 +73,7 @@ use monolake_core::{ use service_async::{AsyncMakeService, MakeService, ParamMaybeRef, ParamRef, Service}; use tracing::{debug, info}; -use crate::http::{generate_response, HttpVersion}; +use crate::http::{HttpVersion, generate_response}; type PooledHttpConnector = HttpConnector; #[cfg(feature = "tls")] @@ -392,10 +392,10 @@ where } } AcceptedAddr::Unix(addr) => { - if let Some(path) = addr.as_pathname().and_then(|s| s.to_str()) { - if let Ok(value) = HeaderValue::from_str(path) { - headers.insert(header::FORWARDED, value); - } + if let Some(path) = addr.as_pathname().and_then(|s| s.to_str()) + && let Ok(value) = HeaderValue::from_str(path) + { + headers.insert(header::FORWARDED, value); } } } diff --git a/monolake-services/src/http/util.rs b/monolake-services/src/http/util.rs index f66c546..9d4fad0 100644 --- a/monolake-services/src/http/util.rs +++ b/monolake-services/src/http/util.rs @@ -40,7 +40,7 @@ impl AccompanyPairBase { pub(crate) fn stage1( mut self: Pin<&mut Self>, future1: F1, - ) -> AccompanyPairS1 { + ) -> AccompanyPairS1<'_, F1, F2, FACC, T> { unsafe { self.as_mut().get_unchecked_mut().main.assume_init_mut().a = ManuallyDrop::new(future1); } @@ -50,14 +50,14 @@ impl AccompanyPairBase { pub(crate) fn stage2( mut self: Pin<&mut Self>, future2: F2, - ) -> AccompanyPairS2 { + ) -> AccompanyPairS2<'_, F1, F2, FACC, T> { unsafe { self.as_mut().get_unchecked_mut().main.assume_init_mut().b = ManuallyDrop::new(future2); } AccompanyPairS2(self) } - pub(crate) const fn stage3(self: Pin<&mut Self>) -> AccompanyPairS3 { + pub(crate) const fn stage3(self: Pin<&mut Self>) -> AccompanyPairS3<'_, F1, F2, FACC, T> { AccompanyPairS3(self) } } diff --git a/monolake-services/src/hyper/mod.rs b/monolake-services/src/hyper/mod.rs index 855d444..5a048f0 100644 --- a/monolake-services/src/hyper/mod.rs +++ b/monolake-services/src/hyper/mod.rs @@ -56,14 +56,14 @@ use http::{Request, Response}; use hyper::body::{Body, Incoming}; use hyper_util::server::conn::auto::Builder; use monoio::io::{ - poll_io::{AsyncRead, AsyncWrite}, IntoPollIo, + poll_io::{AsyncRead, AsyncWrite}, }; pub use monoio_compat::hyper::{MonoioExecutor, MonoioIo}; use monolake_core::http::HttpHandler; use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, Service, + layer::{FactoryLayer, layer_fn}, }; use crate::tcp::Accept; diff --git a/monolake-services/src/lib.rs b/monolake-services/src/lib.rs index 2388ae6..3243be6 100644 --- a/monolake-services/src/lib.rs +++ b/monolake-services/src/lib.rs @@ -1,4 +1,3 @@ -#![feature(let_chains)] #![feature(impl_trait_in_assoc_type)] //! # Monolake Services //! diff --git a/monolake-services/src/proxy_protocol/mod.rs b/monolake-services/src/proxy_protocol/mod.rs index b199da2..55c4270 100644 --- a/monolake-services/src/proxy_protocol/mod.rs +++ b/monolake-services/src/proxy_protocol/mod.rs @@ -36,11 +36,11 @@ use monoio::{ buf::IoBufMut, io::{AsyncReadRent, AsyncWriteRent, PrefixedReadIo}, }; -use monolake_core::{context::RemoteAddr, listener::AcceptedAddr, AnyError}; -use proxy_protocol::{parse, version1, version2, ParseError, ProxyHeader}; +use monolake_core::{AnyError, context::RemoteAddr, listener::AcceptedAddr}; +use proxy_protocol::{ParseError, ProxyHeader, parse, version1, version2}; use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, ParamSet, Service, + layer::{FactoryLayer, layer_fn}, }; use crate::tcp::Accept; diff --git a/monolake-services/src/tcp/echo.rs b/monolake-services/src/tcp/echo.rs index 9cb1cf9..28b291d 100644 --- a/monolake-services/src/tcp/echo.rs +++ b/monolake-services/src/tcp/echo.rs @@ -2,8 +2,8 @@ use std::{convert::Infallible, io}; use monoio::io::{AsyncReadRent, AsyncWriteRent, AsyncWriteRentExt}; use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, Param, Service, + layer::{FactoryLayer, layer_fn}, }; pub struct EchoService { diff --git a/monolake-services/src/thrift/ttheader.rs b/monolake-services/src/thrift/ttheader.rs index 655fdb3..0e4e34c 100644 --- a/monolake-services/src/thrift/ttheader.rs +++ b/monolake-services/src/thrift/ttheader.rs @@ -55,13 +55,13 @@ use std::{convert::Infallible, fmt::Debug, time::Duration}; use certain_map::{Attach, Fork}; -use monoio::io::{sink::SinkExt, stream::Stream, AsyncReadRent, AsyncWriteRent}; +use monoio::io::{AsyncReadRent, AsyncWriteRent, sink::SinkExt, stream::Stream}; use monoio_codec::Framed; use monoio_thrift::codec::ttheader::{RawPayloadCodec, TTHeaderPayloadCodec}; -use monolake_core::{context::PeerAddr, thrift::ThriftHandler, AnyError}; +use monolake_core::{AnyError, context::PeerAddr, thrift::ThriftHandler}; use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, Param, ParamRef, Service, + layer::{FactoryLayer, layer_fn}, }; use tracing::{error, info, trace, warn}; diff --git a/monolake-services/src/tls/mod.rs b/monolake-services/src/tls/mod.rs index 18a7f83..e6b64d6 100644 --- a/monolake-services/src/tls/mod.rs +++ b/monolake-services/src/tls/mod.rs @@ -45,8 +45,8 @@ use std::io::Cursor; use monolake_core::AnyError; use native_tls::Identity; use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, Param, Service, + layer::{FactoryLayer, layer_fn}, }; pub use self::{nativetls::NativeTlsService, rustls::RustlsService}; @@ -178,8 +178,7 @@ where .map_err(Into::into), UnifiedTlsFactory::Native(inner) => inner .make_via_ref(UnifiedTlsService::as_native(old)) - .map(UnifiedTlsService::Native) - .map_err(Into::into), + .map(UnifiedTlsService::Native), UnifiedTlsFactory::None(inner) => inner .make_via_ref(UnifiedTlsService::as_none(old)) .map(UnifiedTlsService::None) @@ -214,8 +213,7 @@ where UnifiedTlsFactory::Native(inner) => inner .make_via_ref(UnifiedTlsService::as_native(old)) .await - .map(UnifiedTlsService::Native) - .map_err(Into::into), + .map(UnifiedTlsService::Native), UnifiedTlsFactory::None(inner) => inner .make_via_ref(UnifiedTlsService::as_none(old)) .await diff --git a/monolake-services/src/tls/nativetls.rs b/monolake-services/src/tls/nativetls.rs index a5258c9..2e1de74 100644 --- a/monolake-services/src/tls/nativetls.rs +++ b/monolake-services/src/tls/nativetls.rs @@ -5,8 +5,8 @@ use monoio_native_tls::{TlsAcceptor, TlsStream}; use monolake_core::AnyError; use native_tls::Identity; use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, Param, Service, + layer::{FactoryLayer, layer_fn}, }; use crate::tcp::Accept; diff --git a/monolake-services/src/tls/rustls.rs b/monolake-services/src/tls/rustls.rs index 06473f5..7104c87 100644 --- a/monolake-services/src/tls/rustls.rs +++ b/monolake-services/src/tls/rustls.rs @@ -5,8 +5,8 @@ use monoio_rustls::{ServerTlsStream, TlsAcceptor}; use monolake_core::AnyError; use rustls::ServerConfig; use service_async::{ - layer::{layer_fn, FactoryLayer}, AsyncMakeService, MakeService, Param, Service, + layer::{FactoryLayer, layer_fn}, }; use crate::tcp::Accept; diff --git a/monolake/src/config/manager.rs b/monolake/src/config/manager.rs index 1e25d0f..b87580d 100644 --- a/monolake/src/config/manager.rs +++ b/monolake/src/config/manager.rs @@ -122,7 +122,7 @@ where } } (false, false) => { - panic!("unexpected error: illegal key {}", key); + panic!("unexpected error: illegal key {key}"); } }; patches.push(patch); diff --git a/monolake/src/config/mod.rs b/monolake/src/config/mod.rs index 805cfe4..ebdce52 100644 --- a/monolake/src/config/mod.rs +++ b/monolake/src/config/mod.rs @@ -23,14 +23,6 @@ pub struct Config { pub servers: HashMap>, } -#[derive(Clone, Debug, Serialize, Deserialize, Default, PartialEq, Eq)] -#[serde(rename_all = "snake_case")] -pub enum ProxyType { - #[default] - Http, - Thrift, -} - #[derive(Debug, Clone)] pub struct ServerConfig { #[allow(unused)]