-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewriting dispatcher and connection (#10)
* Fix passing dispatcher queue parameter * TCP writer in separate task * Revert "TCP writer in separate task" This reverts commit 3962868. * Attempt to simultaniously send and receive * State in connection separated from TCP streams * Separate tasks for read and write to TCP stream * Version with split, not into_split * Revert "Version with split, not into_split" This reverts commit 640f48e. * Mutex instead of BiLock * Attempt to reintroduce internal queue to writer * Another bench * Attempt to decouple writer and internal queue * Attempt to remove writer task * Revert "Attempt to remove writer task" This reverts commit 21381c8. * Cleaner version without permit and options * Final changes of new Connection * Remove unnecessary dependency
- Loading branch information
Showing
8 changed files
with
444 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[package] | ||
name = "tarantool-rs" | ||
description = "Asyncronous tokio-based client for Tarantool" | ||
version = "0.0.9" | ||
version = "0.0.10" | ||
edition = "2021" | ||
authors = ["Andrey Kononov [email protected]"] | ||
license = "MIT" | ||
|
@@ -26,6 +26,7 @@ serde = { version = "1", features = ["derive"] } | |
sha-1 = "0.10" | ||
thiserror = "1" | ||
tokio = { version = "1", features = ["rt", "net", "io-util", "macros", "time"] } | ||
tokio-stream = "0.1" | ||
tokio-util = { version = "0.7", default-features = false, features = ["codec"] } | ||
tracing = { version = "0.1", features = ["log"] } | ||
|
||
|
@@ -40,6 +41,7 @@ serde_json = "1" | |
tokio = { version = "1", features = ["full"] } | ||
tracing-test = { version = "0.2", features = ["no-env-filter"] } | ||
tarantool-test-container = { path = "tarantool-test-container" } | ||
rusty_tarantool = "*" | ||
|
||
[[example]] | ||
name = "cli_client" | ||
|
@@ -60,3 +62,7 @@ harness = false | |
[[bench]] | ||
name = "compare" | ||
harness = false | ||
|
||
[[bench]] | ||
name = "simple_loop" | ||
harness = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use std::time::{Duration, Instant}; | ||
|
||
use futures::{stream::repeat_with, StreamExt}; | ||
use tarantool_rs::{Connection, ExecutorExt}; | ||
|
||
type TarantoolTestContainer = tarantool_test_container::TarantoolTestContainer< | ||
tarantool_test_container::TarantoolDefaultArgs, | ||
>; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), anyhow::Error> { | ||
let container = TarantoolTestContainer::default(); | ||
|
||
let conn = Connection::builder() | ||
.internal_simultaneous_requests_threshold(1000) | ||
.build(format!("127.0.0.1:{}", container.connect_port())) | ||
.await?; | ||
// let conn = rusty_tarantool::tarantool::ClientConfig::new( | ||
// format!("127.0.0.1:{}", container.connect_port()), | ||
// "guest", | ||
// "", | ||
// ) | ||
// .build(); | ||
// conn.ping().await?; | ||
|
||
let mut counter = 0u64; | ||
let mut last_measured_counter = 0; | ||
let mut last_measured_ts = Instant::now(); | ||
|
||
let interval_secs = 2; | ||
let interval = Duration::from_secs(interval_secs); | ||
|
||
let mut stream = repeat_with(|| conn.ping()).buffer_unordered(1000); | ||
while let _ = stream.next().await { | ||
counter += 1; | ||
if last_measured_ts.elapsed() > interval { | ||
last_measured_ts = Instant::now(); | ||
let counter_diff = counter - last_measured_counter; | ||
last_measured_counter = counter; | ||
println!( | ||
"Iterations over last {interval_secs} seconds: {counter_diff}, per second: {}", | ||
counter_diff / interval_secs | ||
); | ||
} | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.