-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
configure the inner client of either BigTableConnection or BigTable (#96
) * configure the inner client of either BigTableConnection or BigTable to change settings like max_decoding_message_size * trim unused use statements
- Loading branch information
1 parent
be21a8e
commit b4b5244
Showing
3 changed files
with
61 additions
and
0 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
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,41 @@ | ||
use bigtable_rs::bigtable; | ||
use env_logger; | ||
use gcp_auth::CustomServiceAccount; | ||
use std::error::Error; | ||
use std::sync::Arc; | ||
use std::time::Duration; | ||
use std::usize; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn Error>> { | ||
env_logger::init(); | ||
|
||
let project_id = "project-1"; | ||
let instance_name = "instance-1"; | ||
let channel_size = 4; | ||
let timeout = Duration::from_secs(10); | ||
|
||
let json_path: &str = "examples/src/custom_path_fake_key.json"; | ||
// make a bigtable client | ||
let mut connection = bigtable::BigTableConnection::new_with_token_provider( | ||
project_id, | ||
instance_name, | ||
false, | ||
channel_size, | ||
Some(timeout), | ||
Arc::new(CustomServiceAccount::from_file(json_path).unwrap()), | ||
)?; | ||
|
||
// update the config for the inner client of the connection | ||
connection | ||
.configure_inner_client(|inner_client| inner_client.max_decoding_message_size(usize::MAX)); | ||
|
||
let mut client = connection.client(); | ||
|
||
// or update the config one step later | ||
client.configure_inner_client(|inner_client| { | ||
inner_client.max_decoding_message_size(2 * 1024 * 1024) | ||
}); | ||
|
||
Ok(()) | ||
} |