1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use google_cloud_gax::conn::Environment;
use google_cloud_gax::grpc::Code;
use google_cloud_gax::retry::RetrySetting;
use std::env::var;
use google_cloud_token::NopeTokenSourceProvider;
use std::time::Duration;
pub mod client;
pub mod database;
pub mod instance;
pub const SCOPES: [&str; 2] = [
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/spanner.admin",
];
pub struct AdminClientConfig {
pub environment: Environment,
}
impl Default for AdminClientConfig {
fn default() -> Self {
AdminClientConfig {
environment: match var("SPANNER_EMULATOR_HOST").ok() {
Some(v) => Environment::Emulator(v),
None => Environment::GoogleCloud(Box::new(NopeTokenSourceProvider {})),
},
}
}
}
pub fn default_retry_setting() -> RetrySetting {
RetrySetting {
from_millis: 50,
max_delay: Some(Duration::from_secs(10)),
factor: 1u64,
take: 20,
codes: vec![Code::Unavailable, Code::Unknown, Code::DeadlineExceeded],
}
}