rust-server-sdk icon indicating copy to clipboard operation
rust-server-sdk copied to clipboard

Support for http_proxy

Open butlerx opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe.

We use an HTTP Proxy (squid) to connect to the internet. In the LD SDKs for other languages, we only have to specify HTTP_PROXY=http://proxy.internal:8080 to tell the SDK to connect to the internet via the proxy. This isn't supported in Rust though

Describe the solution you'd like When HTTP_PROXY is defined in the environment the LD client would use the proxy to connect to the ld backend

Current workaround

use hyper::client::HttpConnector;
use hyper_proxy::{Intercept, Proxy, ProxyConnector};
use launchdarkly_server_sdk::{
    Client, ConfigBuilder, EventProcessorBuilder, ServiceEndpointsBuilder,
    StreamingDataSourceBuilder,
};
pub use launchdarkly_server_sdk::{Context, ContextBuilder};
.....
    let ld_config = if let Ok(http_proxy) = std::env::var("HTTP_PROXY") {
        let proxy_uri = http_proxy.parse()?;
        let proxy = Proxy::new(Intercept::All, proxy_uri);
        let connector = HttpConnector::new();
        let proxy_connector = ProxyConnector::from_proxy(connector, proxy).unwrap();
        let mut data_source_builder = StreamingDataSourceBuilder::default();
        data_source_builder.https_connector(proxy_connector.clone());
        let mut event_processor_builder = EventProcessorBuilder::default();
        event_processor_builder.https_connector(proxy_connector);
        ConfigBuilder::new(&ld_sdk_key)
            .event_processor(&event_processor_builder)
            .data_source(&data_source_builder)
            .build()
    } else {
        ConfigBuilder::new(&ld_sdk_key).build()
    };

butlerx avatar Jul 01 '24 13:07 butlerx

Thank you for filing this request. I cannot provide a timeline given competing priorities and timelines, but we are tracking this request internally and will notify you once we have added support.

Internal ticket number sc-249422.

keelerm84 avatar Jul 09 '24 14:07 keelerm84