|
|
@@ -122,6 +122,9 @@ impl BigTableConnection {
|
|
|
///
|
|
|
/// The BIGTABLE_EMULATOR_HOST environment variable is also respected.
|
|
|
///
|
|
|
+ /// The BIGTABLE_PROXY environment variable is used to configure the gRPC connection through a
|
|
|
+ /// forward proxy (see HTTP_PROXY).
|
|
|
+ ///
|
|
|
pub async fn new(
|
|
|
instance_name: &str,
|
|
|
app_profile_id: &str,
|
|
|
@@ -180,9 +183,28 @@ impl BigTableConnection {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ let mut http = hyper::client::HttpConnector::new();
|
|
|
+ http.enforce_http(false);
|
|
|
+ let channel = match std::env::var("BIGTABLE_PROXY") {
|
|
|
+ Ok(proxy_uri) => {
|
|
|
+ let proxy = hyper_proxy::Proxy::new(
|
|
|
+ hyper_proxy::Intercept::All,
|
|
|
+ proxy_uri
|
|
|
+ .parse::<http::Uri>()
|
|
|
+ .map_err(|err| Error::InvalidUri(proxy_uri, err.to_string()))?,
|
|
|
+ );
|
|
|
+ let mut proxy_connector =
|
|
|
+ hyper_proxy::ProxyConnector::from_proxy(http, proxy)?;
|
|
|
+ // tonic handles TLS as a separate layer
|
|
|
+ proxy_connector.set_tls(None);
|
|
|
+ endpoint.connect_with_connector_lazy(proxy_connector)
|
|
|
+ }
|
|
|
+ _ => endpoint.connect_with_connector_lazy(http),
|
|
|
+ };
|
|
|
+
|
|
|
Ok(Self {
|
|
|
access_token: Some(access_token),
|
|
|
- channel: endpoint.connect_lazy(),
|
|
|
+ channel,
|
|
|
table_prefix,
|
|
|
app_profile_id: app_profile_id.to_string(),
|
|
|
timeout,
|