Skip to content

Commit

Permalink
Migrate ntex to async fn in trait
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Jan 7, 2024
1 parent 2e12cc6 commit 4950eb4
Show file tree
Hide file tree
Showing 57 changed files with 598 additions and 954 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ ntex-util = { path = "ntex-util" }
ntex-glommio = { path = "ntex-glommio" }
ntex-tokio = { path = "ntex-tokio" }
ntex-async-std = { path = "ntex-async-std" }

ntex-h2 = { git = "https://github.com/ntex-rs/ntex-h2.git", branch = "async-fn-in-trait" }
2 changes: 1 addition & 1 deletion ntex-bytes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ simdutf8 = { version = "0.1.4", optional = true }
[dev-dependencies]
serde_test = "1.0"
serde_json = "1.0"
ntex = { version = "0.7.0", features = ["tokio"] }
ntex = { version = "1.0.0", features = ["tokio"] }
2 changes: 1 addition & 1 deletion ntex-connect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ webpki-roots = { version = "0.25", optional = true }
[dev-dependencies]
rand = "0.8"
env_logger = "0.10"
ntex = { version = "0.7.0", features = ["tokio"] }
ntex = { version = "1.0", features = ["tokio"] }
2 changes: 1 addition & 1 deletion ntex-io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ pin-project-lite = "0.2"
rand = "0.8"
env_logger = "0.10"

ntex = { version = "0.7", features = ["tokio"] }
ntex = { version = "1.0.0", features = ["tokio"] }
6 changes: 3 additions & 3 deletions ntex-io/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,10 +839,10 @@ mod tests {
Poll::Ready(Err(()))
}

async fn call<'a>(
&'a self,
async fn call(
&self,

Check warning on line 843 in ntex-io/src/dispatcher.rs

View check run for this annotation

Codecov / codecov/patch

ntex-io/src/dispatcher.rs#L842-L843

Added lines #L842 - L843 were not covered by tests
_: DispatchItem<BytesCodec>,
_: ServiceCtx<'a, Self>,
_: ServiceCtx<'_, Self>,
) -> Result<Self::Response, Self::Error> {
Ok(None)

Check warning on line 847 in ntex-io/src/dispatcher.rs

View check run for this annotation

Codecov / codecov/patch

ntex-io/src/dispatcher.rs#L845-L847

Added lines #L845 - L847 were not covered by tests
}
Expand Down
2 changes: 1 addition & 1 deletion ntex-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ syn = { version = "^1", features = ["full", "parsing"] }
proc-macro2 = "^1"

[dev-dependencies]
ntex = { version = "0.7.0", features = ["tokio"] }
ntex = { version = "1.0.0", features = ["tokio"] }
futures = "0.3"
env_logger = "0.10"
4 changes: 2 additions & 2 deletions ntex-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ pin-project-lite = "0.2.6"
slab = "0.4"

[dev-dependencies]
ntex = { version = "0.7.0", features = ["tokio"] }
ntex-util = "0.3.0"
ntex = { version = "1.0", features = ["tokio"] }
ntex-util = "1.0.0"
12 changes: 6 additions & 6 deletions ntex-service/src/and_then.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ mod tests {
Poll::Ready(Ok(()))
}

async fn call<'a>(
&'a self,
async fn call(
&self,
req: &'static str,
_: ServiceCtx<'a, Self>,
_: ServiceCtx<'_, Self>,
) -> Result<Self::Response, ()> {
Ok(req)
}
Expand All @@ -131,10 +131,10 @@ mod tests {
Poll::Ready(Ok(()))
}

async fn call<'a>(
&'a self,
async fn call(
&self,
req: &'static str,
_: ServiceCtx<'a, Self>,
_: ServiceCtx<'_, Self>,
) -> Result<Self::Response, ()> {
Ok((req, "srv2"))
}
Expand Down
2 changes: 1 addition & 1 deletion ntex-service/src/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ mod tests {
type Response = ();
type Error = ();

async fn call<'a>(&'a self, _: (), _: ServiceCtx<'a, Self>) -> Result<(), ()> {
async fn call(&self, _: (), _: ServiceCtx<'_, Self>) -> Result<(), ()> {
Ok(())
}
}
Expand Down
6 changes: 3 additions & 3 deletions ntex-service/src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ mod tests {
self.1.poll_ready(cx).map(|_| Ok(()))
}

async fn call<'a>(
&'a self,
async fn call(
&self,
req: &'static str,
ctx: ServiceCtx<'a, Self>,
ctx: ServiceCtx<'_, Self>,
) -> Result<Self::Response, Self::Error> {
let _ = ctx.clone();
Ok(req)
Expand Down
2 changes: 1 addition & 1 deletion ntex-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub use self::pipeline::{Pipeline, PipelineCall};
/// type Response = u64;
/// type Error = Infallible;
///
/// async fn call<'a>(&'a self, req: u8, _: ServiceCtx<'a, Self>) -> Result<Self::Response, Self::Error> {
/// async fn call(&self, req: u8, _: ServiceCtx<'_, Self>) -> Result<Self::Response, Self::Error> {
/// Ok(req as u64)
/// }
/// }
Expand Down
2 changes: 1 addition & 1 deletion ntex-service/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ mod tests {
Poll::Ready(Ok(()))
}

async fn call<'a>(&'a self, _: (), _: ServiceCtx<'a, Self>) -> Result<(), ()> {
async fn call(&self, _: (), _: ServiceCtx<'_, Self>) -> Result<(), ()> {
Ok(())
}
}
Expand Down
2 changes: 1 addition & 1 deletion ntex-service/src/map_err.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ mod tests {
}
}

async fn call<'a>(&'a self, _: (), _: ServiceCtx<'a, Self>) -> Result<(), ()> {
async fn call(&self, _: (), _: ServiceCtx<'_, Self>) -> Result<(), ()> {
Err(())
}
}
Expand Down
6 changes: 3 additions & 3 deletions ntex-service/src/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ mod tests {
self.0.poll_ready(cx)
}

async fn call<'a>(
&'a self,
async fn call(
&self,
req: R,
ctx: ServiceCtx<'a, Self>,
ctx: ServiceCtx<'_, Self>,
) -> Result<S::Response, S::Error> {
ctx.call(&self.0, req).await
}
Expand Down
12 changes: 6 additions & 6 deletions ntex-service/src/then.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ mod tests {
Poll::Ready(Ok(()))
}

async fn call<'a>(
&'a self,
async fn call(
&self,
req: Result<&'static str, &'static str>,
_: ServiceCtx<'a, Self>,
_: ServiceCtx<'_, Self>,
) -> Result<&'static str, ()> {
match req {
Ok(msg) => Ok(msg),
Expand All @@ -138,10 +138,10 @@ mod tests {
Poll::Ready(Ok(()))
}

async fn call<'a>(
&'a self,
async fn call(
&self,
req: Result<&'static str, ()>,
_: ServiceCtx<'a, Self>,
_: ServiceCtx<'_, Self>,
) -> Result<Self::Response, ()> {
match req {
Ok(msg) => Ok((msg, "ok")),
Expand Down
2 changes: 1 addition & 1 deletion ntex-tls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ tls_openssl = { version = "0.10", package = "openssl", optional = true }
tls_rust = { version = "0.21", package = "rustls", optional = true }

[dev-dependencies]
ntex = { version = "0.7", features = ["openssl", "rustls", "tokio"] }
ntex = { version = "1.0", features = ["openssl", "rustls", "tokio"] }
env_logger = "0.10"
rustls-pemfile = "1.0"
webpki-roots = "0.25"
2 changes: 1 addition & 1 deletion ntex-util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ futures-sink = { version = "0.3", default-features = false, features = ["alloc"]
pin-project-lite = "0.2.9"

[dev-dependencies]
ntex = { version = "0.7", features = ["tokio"] }
ntex = { version = "1.0.0", features = ["tokio"] }
ntex-bytes = "0.1.21"
ntex-macros = "0.1.3"
futures-util = { version = "0.3", default-features = false, features = ["alloc"] }
2 changes: 1 addition & 1 deletion ntex-util/src/services/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ mod tests {
}
}

async fn call<'a>(&'a self, _: (), _: ServiceCtx<'a, Self>) -> Result<(), ()> {
async fn call(&self, _: (), _: ServiceCtx<'_, Self>) -> Result<(), ()> {
self.0.ready.set(false);
self.0.count.set(self.0.count.get() + 1);
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion ntex-util/src/services/inflight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ mod tests {
type Response = ();
type Error = ();

async fn call<'a>(&'a self, _: (), _: ServiceCtx<'a, Self>) -> Result<(), ()> {
async fn call(&self, _: (), _: ServiceCtx<'_, Self>) -> Result<(), ()> {
let _ = self.0.recv().await;
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion ntex-util/src/services/onerequest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ mod tests {
type Response = ();
type Error = ();

async fn call<'a>(&'a self, _: (), _: ServiceCtx<'a, Self>) -> Result<(), ()> {
async fn call(&self, _: (), _: ServiceCtx<'_, Self>) -> Result<(), ()> {
let _ = self.0.recv().await;
Ok::<_, ()>(())
}
Expand Down
6 changes: 1 addition & 5 deletions ntex-util/src/services/timeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,7 @@ mod tests {
type Response = ();
type Error = SrvError;

async fn call<'a>(
&'a self,
_: (),
_: ServiceCtx<'a, Self>,
) -> Result<(), SrvError> {
async fn call(&self, _: (), _: ServiceCtx<'_, Self>) -> Result<(), SrvError> {
crate::time::sleep(self.0).await;
Ok::<_, SrvError>(())
}
Expand Down
4 changes: 2 additions & 2 deletions ntex-util/src/services/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ mod tests {
Poll::Ready(())
}

async fn call<'a>(&'a self, _: (), _: ServiceCtx<'a, Self>) -> Result<usize, ()> {
async fn call(&self, _: (), _: ServiceCtx<'_, Self>) -> Result<usize, ()> {
Ok(1)
}
}
Expand All @@ -273,7 +273,7 @@ mod tests {
Poll::Ready(())
}

async fn call<'a>(&'a self, _: (), _: ServiceCtx<'a, Self>) -> Result<usize, ()> {
async fn call(&self, _: (), _: ServiceCtx<'_, Self>) -> Result<usize, ()> {
Ok(2)
}
}
Expand Down
4 changes: 4 additions & 0 deletions ntex/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

## [1.0.0] - 2024-01-0x

* Use "async fn" in trait for Service definition

## [0.7.17] - 2024-01-05

* Allow to set default response payload limit and timeout
Expand Down
20 changes: 10 additions & 10 deletions ntex/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ntex"
version = "0.7.17"
version = "1.0.0"
authors = ["ntex contributors <[email protected]>"]
description = "Framework for composable network services"
readme = "README.md"
Expand Down Expand Up @@ -49,20 +49,20 @@ async-std = ["ntex-rt/async-std", "ntex-async-std", "ntex-connect/async-std"]

[dependencies]
ntex-codec = "0.6.2"
ntex-connect = "0.3.4"
ntex-connect = "1.0.0"
ntex-http = "0.1.11"
ntex-router = "0.5.2"
ntex-service = "1.2.7"
ntex-service = "2.0.0"
ntex-macros = "0.1.3"
ntex-util = "0.3.4"
ntex-util = "1.0.0"
ntex-bytes = "0.1.21"
ntex-h2 = "0.4.4"
ntex-h2 = "0.5.0"
ntex-rt = "0.4.11"
ntex-io = "0.3.17"
ntex-tls = "0.3.3"
ntex-tokio = { version = "0.3.1", optional = true }
ntex-glommio = { version = "0.3.1", optional = true }
ntex-async-std = { version = "0.3.2", optional = true }
ntex-io = "1.0.0"
ntex-tls = "1.0.0"
ntex-tokio = { version = "0.4.0", optional = true }
ntex-glommio = { version = "0.4.0", optional = true }
ntex-async-std = { version = "0.4.0", optional = true }

async-channel = "2.1"
base64 = "0.21"
Expand Down
4 changes: 2 additions & 2 deletions ntex/src/http/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,10 @@ where
#[cfg(test)]
mod tests {
use futures_util::stream;
use std::io;
use std::{future::poll_fn, io};

use super::*;
use crate::util::{poll_fn, Ready};
use crate::util::Ready;

impl Body {
pub(crate) fn get_ref(&self) -> &[u8] {
Expand Down
Loading

0 comments on commit 4950eb4

Please sign in to comment.