Skip to content

Use ntex-service 3.0 #10

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

Merged
merged 1 commit into from
May 28, 2024
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
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

## [2.0.0] - 2024-05-28

* Use ntex-service 3.0

## [1.0.0] - 2024-01-09

* Fix decode array #8
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ntex-redis"
version = "1.0.0"
version = "2.0.0"
authors = ["ntex contributors <[email protected]>"]
description = "Redis client"
documentation = "https://docs.rs/ntex-redis"
Expand All @@ -12,13 +12,13 @@ exclude = [".gitignore", ".travis.yml", ".cargo/config"]
edition = "2018"

[dependencies]
ntex = "1.0"
ntex = "2"
itoa = "1.0"
btoi = "0.4"
log = "0.4"
derive_more = "0.99"

[dev-dependencies]
rand = "0.8"
env_logger = "0.10"
ntex = { version = "1.0", features = ["tokio"] }
env_logger = "0.11"
ntex = { version = "2", features = ["tokio"] }
17 changes: 10 additions & 7 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::collections::VecDeque;
use std::{cell::RefCell, fmt, future::poll_fn, rc::Rc, task::Context, task::Poll};
use std::{cell::RefCell, fmt, future::poll_fn, rc::Rc, task::Poll};

use ntex::io::{IoBoxed, IoRef, OnDisconnect, RecvError};
use ntex::util::ready;
Expand Down Expand Up @@ -120,12 +120,15 @@ impl Service<Request> for Client {
type Response = Response;
type Error = Error;

fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
if self.disconnect.poll_ready(cx).is_ready() {
Poll::Ready(Err(Error::PeerGone(None)))
} else {
Poll::Ready(Ok(()))
}
async fn ready(&self, _: ServiceCtx<'_, Self>) -> Result<(), Self::Error> {
poll_fn(|cx| {
if self.disconnect.poll_ready(cx).is_ready() {
Poll::Ready(Err(Error::PeerGone(None)))
} else {
Poll::Ready(Ok(()))
}
})
.await
}

async fn call(&self, req: Request, _: ServiceCtx<'_, Self>) -> Result<Response, Error> {
Expand Down
Loading