-
Notifications
You must be signed in to change notification settings - Fork 176
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
feat: expose ConnectionGuard as request extension #1443
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -207,7 +207,7 @@ async fn ws_method_call_works_over_proxy_stream() { | |
} | ||
|
||
#[tokio::test] | ||
async fn extensions_with_different_ws_clients() { | ||
async fn connection_id_extension_with_different_ws_clients() { | ||
init_logger(); | ||
|
||
let server_addr = server().await; | ||
|
@@ -225,6 +225,31 @@ async fn extensions_with_different_ws_clients() { | |
assert_ne!(connection_id, second_connection_id); | ||
} | ||
|
||
#[tokio::test] | ||
async fn connection_guard_extension_with_different_ws_clients() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's sufficient with one client but this does hurt, thanks :) |
||
init_logger(); | ||
|
||
let server_addr = server().await; | ||
let server_url = format!("ws://{}", server_addr); | ||
|
||
// First connected retrieves initial information from ConnectionGuard. | ||
let first_client = WsClientBuilder::default().build(&server_url).await.unwrap(); | ||
let first_max_connections: usize = first_client.request("get_max_connections", rpc_params![]).await.unwrap(); | ||
let first_available_connections: usize = | ||
first_client.request("get_available_connections", rpc_params![]).await.unwrap(); | ||
|
||
assert_eq!(first_available_connections, first_max_connections - 1); | ||
|
||
// Second client ensure max connections stays the same, but available connections is decreased. | ||
let second_client = WsClientBuilder::default().build(&server_url).await.unwrap(); | ||
let second_max_connections: usize = second_client.request("get_max_connections", rpc_params![]).await.unwrap(); | ||
let second_available_connections: usize = | ||
second_client.request("get_available_connections", rpc_params![]).await.unwrap(); | ||
|
||
assert_eq!(second_max_connections, first_max_connections); | ||
assert_eq!(second_available_connections, second_max_connections - 2); | ||
} | ||
|
||
#[tokio::test] | ||
async fn ws_method_call_str_id_works() { | ||
init_logger(); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, we could probably merge the ConnectionID and ConnectionGuard as some point to another type e.g. ConnectionDetails or something