Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade async-channel #236

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions ntex-io/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,8 +855,8 @@ impl Future for OnDisconnect {

#[cfg(test)]
mod tests {
use ntex_codec::BytesCodec;
use ntex_bytes::Bytes;
use ntex_codec::BytesCodec;

use super::*;
use crate::testing::IoTest;
Expand Down Expand Up @@ -891,7 +891,11 @@ mod tests {
let server = Io::new(server);
assert!(server.eq(&server));

server.send(Bytes::from_static(b"GET /test HTTP/1"), &BytesCodec).await.ok().unwrap();
server
.send(Bytes::from_static(b"GET /test HTTP/1"), &BytesCodec)
.await
.ok()
.unwrap();
let item = client.read_any();
assert_eq!(item, "GET /test HTTP/1");
}
Expand Down
4 changes: 4 additions & 0 deletions ntex-rt/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

## [0.4.10] - 2023-11-02

* Upgrade async-channel to 2.0

## [0.4.9] - 2023-04-11

* Chore upgrade glommio to 0.8
Expand Down
6 changes: 3 additions & 3 deletions ntex-rt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ntex-rt"
version = "0.4.9"
version = "0.4.10"
authors = ["ntex contributors <team@ntex.rs>"]
description = "ntex runtime"
keywords = ["network", "framework", "async", "futures"]
Expand Down Expand Up @@ -28,8 +28,8 @@ tokio = ["tok-io"]
async-std = ["async_std/unstable"]

[dependencies]
async-oneshot = "0.5.0"
async-channel = "1.8.0"
async-oneshot = "0.5"
async-channel = "2.0"
futures-core = "0.3"
log = "0.4"

Expand Down
28 changes: 22 additions & 6 deletions ntex-rt/src/arbiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
static STORAGE: RefCell<HashMap<TypeId, Box<dyn Any>>> = RefCell::new(HashMap::new());
);

type ServerCommandRx = Pin<Box<dyn Stream<Item = SystemCommand>>>;
type ArbiterCommandRx = Pin<Box<dyn Stream<Item = ArbiterCommand>>>;

pub(super) static COUNT: AtomicUsize = AtomicUsize::new(0);

pub(super) enum ArbiterCommand {
Expand Down Expand Up @@ -57,7 +60,13 @@
ADDR.with(|cell| *cell.borrow_mut() = Some(arb.clone()));
STORAGE.with(|cell| cell.borrow_mut().clear());

(arb, ArbiterController { stop: None, rx })
(
arb,
ArbiterController {
stop: None,
rx: Box::pin(rx),
},
)
}

/// Returns the current thread's arbiter's address. If no Arbiter is present, then this
Expand Down Expand Up @@ -97,7 +106,7 @@
// start arbiter controller
crate::spawn(ArbiterController {
stop: Some(stop),
rx: arb_rx,
rx: Box::pin(arb_rx),
});
ADDR.with(|cell| *cell.borrow_mut() = Some(arb.clone()));

Expand Down Expand Up @@ -231,7 +240,7 @@

pub(crate) struct ArbiterController {
stop: Option<oneshot::Sender<i32>>,
rx: Receiver<ArbiterCommand>,
rx: ArbiterCommandRx,
}

impl Drop for ArbiterController {
Expand Down Expand Up @@ -281,10 +290,9 @@
UnregisterArbiter(usize),
}

#[derive(Debug)]
pub(super) struct SystemArbiter {
stop: Option<oneshot::Sender<i32>>,
commands: Receiver<SystemCommand>,
commands: ServerCommandRx,
arbiters: HashMap<usize, Arbiter>,
}

Expand All @@ -294,13 +302,21 @@
commands: Receiver<SystemCommand>,
) -> Self {
SystemArbiter {
commands,
commands: Box::pin(commands),
stop: Some(stop),
arbiters: HashMap::new(),
}
}
}

impl fmt::Debug for SystemArbiter {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SystemArbiter")
.field("arbiters", &self.arbiters)
.finish()
}

Check warning on line 317 in ntex-rt/src/arbiter.rs

View check run for this annotation

Codecov / codecov/patch

ntex-rt/src/arbiter.rs#L313-L317

Added lines #L313 - L317 were not covered by tests
}

impl Future for SystemArbiter {
type Output = ();

Expand Down
10 changes: 5 additions & 5 deletions ntex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ ntex-macros = "0.1.3"
ntex-util = "0.3.3"
ntex-bytes = "0.1.19"
ntex-h2 = "0.4.3"
ntex-rt = "0.4.9"
ntex-rt = "0.4.10"
ntex-io = "0.3.4"
ntex-tls = "0.3.1"
ntex-tokio = { version = "0.3.0", optional = true }
ntex-glommio = { version = "0.3.0", optional = true }
ntex-async-std = { version = "0.3.0", optional = true }

async-oneshot = "0.5.0"
async-channel = "2.0.0"
async-oneshot = "0.5"
async-channel = "2.0"
base64 = "0.21"
bitflags = "2.4"
log = "0.4"
nanorand = { version = "0.7.0", default-features = false, features = ["std", "wyrand"] }
nanorand = { version = "0.7", default-features = false, features = ["std", "wyrand"] }
polling = "3.3"
pin-project-lite = "0.2"
regex = { version = "1.10.1", default-features = false, features = ["std"] }
Expand All @@ -79,7 +79,7 @@ socket2 = "0.5"
thiserror = "1.0"

# http/web framework
httparse = "1.8.0"
httparse = "1.8"
httpdate = "1.0"
encoding_rs = "0.8"
mime = "0.3"
Expand Down
Loading