Skip to content

Commit

Permalink
fix benches & examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mcatanzariti committed Apr 21, 2024
1 parent fa7e7f4 commit 0d53946
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions benches/generic_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async fn get_fred_client() -> fred::clients::RedisClient {
use fred::prelude::*;

let config = RedisConfig::default();
let client = RedisClient::new(config, None, None);
let client = RedisClient::new(config, None, None, None);
client.connect();
client.wait_for_connect().await.unwrap();

Expand All @@ -42,7 +42,7 @@ fn bench_redis_simple_getsetdel_async(b: &mut Bencher) {

let client = get_redis_client();
let runtime = current_thread_runtime();
let con = client.get_async_connection();
let con = client.get_multiplexed_async_connection();
let mut con = runtime.block_on(con).unwrap();

b.iter(|| {
Expand Down
2 changes: 1 addition & 1 deletion benches/multiplexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async fn get_fred_client() -> fred::clients::RedisClient {
use fred::prelude::*;

let config = RedisConfig::default();
let client = RedisClient::new(config, None, None);
let client = RedisClient::new(config, None, None, None);
client.connect();
client.wait_for_connect().await.unwrap();

Expand Down
4 changes: 2 additions & 2 deletions benches/native_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async fn get_fred_client() -> fred::clients::RedisClient {
use fred::prelude::*;

let config = RedisConfig::default();
let client = RedisClient::new(config, None, None);
let client = RedisClient::new(config, None, None, None);
client.connect();
client.wait_for_connect().await.unwrap();

Expand All @@ -42,7 +42,7 @@ fn bench_redis_simple_getsetdel_async(b: &mut Bencher) {

let client = get_redis_client();
let runtime = current_thread_runtime();
let con = client.get_async_connection();
let con = client.get_multiplexed_async_connection();
let mut con = runtime.block_on(con).unwrap();

b.iter(|| {
Expand Down
4 changes: 2 additions & 2 deletions benches/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async fn get_fred_client() -> fred::clients::RedisClient {
use fred::prelude::*;

let config = RedisConfig::default();
let client = RedisClient::new(config, None, None);
let client = RedisClient::new(config, None, None, None);
client.connect();
client.wait_for_connect().await.unwrap();

Expand Down Expand Up @@ -109,7 +109,7 @@ fn bench_redis_async_long_pipeline(b: &mut Bencher) {

let client = get_redis_client();
let runtime = current_thread_runtime();
let mut con = runtime.block_on(client.get_async_connection()).unwrap();
let mut con = runtime.block_on(client.get_multiplexed_async_connection()).unwrap();

b.iter(|| {
runtime
Expand Down
7 changes: 3 additions & 4 deletions examples/axum_crud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use rustis::{
commands::{GenericCommands, StringCommands},
};
use std::{net::SocketAddr, sync::Arc};
use tokio::net::TcpListener;

#[tokio::main]
async fn main() {
Expand All @@ -24,10 +25,8 @@ async fn main() {
// run it
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
let listener = TcpListener::bind(&addr).await.unwrap();
axum::serve(listener, app).await.unwrap();
}

async fn read(
Expand Down
9 changes: 4 additions & 5 deletions examples/axum_long_polling_pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use rustis::{
commands::{ListCommands, PubSubCommands},
};
use std::{net::SocketAddr, sync::Arc, time::Duration};
use tokio::net::TcpListener;

const POLL_TIMEOUT: Duration = Duration::from_secs(10);

Expand Down Expand Up @@ -39,10 +40,8 @@ async fn main() {
// run it
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
axum::Server::bind(&addr)
.serve(app.into_make_service())
.await
.unwrap();
let listener = TcpListener::bind(&addr).await.unwrap();
axum::serve(listener, app).await.unwrap();
}

async fn poll_messages(
Expand Down Expand Up @@ -90,7 +89,7 @@ async fn publish(
return Err(ServiceError::new(
StatusCode::BAD_REQUEST,
"Message not provided",
))
));
};

// data is not sent via pub/sub; the pub/sub API is used only to notify subscriber to check for new notifications
Expand Down

0 comments on commit 0d53946

Please sign in to comment.