-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add the session and pool. #10
Merged
Shylock-Hg
merged 11 commits into
vesoft-inc:master
from
Shylock-Hg:feature/pool_session
Dec 16, 2021
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
74b9597
Add the session and pool.
Shylock-Hg a87e425
Comment the interior mutable.
Shylock-Hg e58472a
Add some methods for value type.
Shylock-Hg bba2218
Try to fit the connection count.
Shylock-Hg d527e20
Support pool expansion.
Shylock-Hg 681af15
Unify the value trait name.
Shylock-Hg eb9a885
Refactor the for loop by map collect.
Shylock-Hg abb6885
Add method to get data set columns size.
Shylock-Hg ed964e4
Add a simple example.
Shylock-Hg b49b9bd
Show the example query result.
Shylock-Hg 9f34ea2
Simplify the data set columns name conversion.
Shylock-Hg 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
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,31 @@ | ||
/* Copyright (c) 2021 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
use nebula_rust::graph_client; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let mut conf = graph_client::pool_config::PoolConfig::new(); | ||
conf.min_connection_pool_size(2) | ||
.max_connection_pool_size(10) | ||
.address("localhost:9669".to_string()); | ||
|
||
let pool = graph_client::connection_pool::ConnectionPool::new(&conf).await; | ||
let session = pool.get_session("root", "nebula", true).await.unwrap(); | ||
|
||
let resp = session.execute("YIELD 1").await.unwrap(); | ||
assert!(resp.error_code == common::types::ErrorCode::SUCCEEDED); | ||
|
||
println!("{:?}", resp.data.as_ref().unwrap()); | ||
println!( | ||
"The result of query `YIELD 1' is {}.", | ||
if let common::types::Value::iVal(v) = resp.data.unwrap().rows[0].values[0] { | ||
v | ||
} else { | ||
panic!() | ||
} | ||
); | ||
} |
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
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.
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.
the connection pop from the list, and if the user does no return it, the pool couldn't close it. You need to make the pool can manage it when the use get it from the pool.
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.
you need to make the connection is ok, here you can get a bad connection
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.
The pool can't access the connection owned by session. It's designed to avoid some data race
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.
The keep-alive will add in later pr.