Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions contract-tests/src/client_entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,19 @@ impl ClientEntity {
create_instance_params: CreateInstanceParams,
connector: HttpsConnector,
) -> Result<Self, BuildError> {
let proxy = create_instance_params
.configuration
.proxy
.unwrap_or_default()
.http_proxy
.unwrap_or_default();
let mut transport_builder = launchdarkly_sdk_transport::HyperTransport::builder();
if !proxy.is_empty() {
transport_builder = transport_builder.proxy_url(proxy.clone());
}

// Create fresh transports for this client to avoid shared connection pool issues
let transport = launchdarkly_sdk_transport::HyperTransport::builder()
.build_with_connector(connector.clone())
.map_err(|e| BuildError::InvalidConfig(e.to_string()))?;
let streaming_https_transport = launchdarkly_sdk_transport::HyperTransport::builder()
let transport = transport_builder
.build_with_connector(connector.clone())
.map_err(|e| BuildError::InvalidConfig(e.to_string()))?;
let mut config_builder =
Expand Down Expand Up @@ -88,7 +96,7 @@ impl ClientEntity {
if let Some(delay) = streaming.initial_retry_delay_ms {
streaming_builder.initial_reconnect_delay(Duration::from_millis(delay));
}
streaming_builder.transport(streaming_https_transport.clone());
streaming_builder.transport(transport.clone());

config_builder = config_builder.data_source(&streaming_builder);
} else if let Some(polling) = create_instance_params.configuration.polling {
Expand All @@ -108,7 +116,7 @@ impl ClientEntity {
// customization we provide is the transport to support testing multiple
// transport implementations.
let mut streaming_builder = StreamingDataSourceBuilder::new();
streaming_builder.transport(streaming_https_transport);
streaming_builder.transport(transport.clone());
config_builder = config_builder.data_source(&streaming_builder);
}

Expand Down
9 changes: 9 additions & 0 deletions contract-tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ struct Status {
capabilities: Vec<String>,
}

#[derive(Deserialize, Debug, Default)]
#[serde(rename_all = "camelCase")]
pub struct ProxyParameters {
pub http_proxy: Option<String>,
}

#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct StreamingParameters {
Expand Down Expand Up @@ -72,6 +78,8 @@ pub struct Configuration {
#[serde(default = "bool::default")]
pub init_can_fail: bool,

pub proxy: Option<ProxyParameters>,

pub streaming: Option<StreamingParameters>,

pub polling: Option<PollingParameters>,
Expand Down Expand Up @@ -103,6 +111,7 @@ async fn status() -> impl Responder {
"tags".to_string(),
"service-endpoints".to_string(),
"context-type".to_string(),
"http-proxy".to_string(),
#[cfg(any(feature = "crypto-aws-lc-rs", feature = "crypto-openssl"))]
"secure-mode-hash".to_string(),
"inline-context-all".to_string(),
Expand Down