@@ -11,13 +11,15 @@ const DEFAULT_EVENTS_BASE_URL: &str = "https://events.launchdarkly.com";
1111
1212use launchdarkly_server_sdk:: {
1313 ApplicationInfo , BuildError , Client , ConfigBuilder , Detail , EventProcessorBuilder ,
14- FlagDetailConfig , FlagValue , NullEventProcessorBuilder , PollingDataSourceBuilder ,
14+ FlagDetailConfig , FlagFilter , FlagValue , NullEventProcessorBuilder , PollingDataSourceBuilder ,
1515 ServiceEndpointsBuilder , StreamingDataSourceBuilder ,
1616} ;
1717
18+ #[ cfg( any( feature = "crypto-aws-lc-rs" , feature = "crypto-openssl" ) ) ]
19+ use crate :: command_params:: SecureModeHashResponse ;
1820use crate :: command_params:: {
1921 ContextBuildParams , ContextConvertParams , ContextParam , ContextResponse ,
20- MigrationOperationResponse , MigrationVariationResponse , SecureModeHashResponse ,
22+ MigrationOperationResponse , MigrationVariationResponse ,
2123} ;
2224use crate :: HttpsConnector ;
2325use crate :: {
@@ -37,6 +39,21 @@ impl ClientEntity {
3739 create_instance_params : CreateInstanceParams ,
3840 connector : HttpsConnector ,
3941 ) -> Result < Self , BuildError > {
42+ let proxy = create_instance_params
43+ . configuration
44+ . proxy
45+ . unwrap_or_default ( )
46+ . http_proxy
47+ . unwrap_or_default ( ) ;
48+ let mut transport_builder = launchdarkly_sdk_transport:: HyperTransport :: builder ( ) ;
49+ if !proxy. is_empty ( ) {
50+ transport_builder = transport_builder. proxy_url ( proxy. clone ( ) ) ;
51+ }
52+
53+ // Create fresh transports for this client to avoid shared connection pool issues
54+ let transport = transport_builder
55+ . build_with_connector ( connector. clone ( ) )
56+ . map_err ( |e| BuildError :: InvalidConfig ( e. to_string ( ) ) ) ?;
4057 let mut config_builder =
4158 ConfigBuilder :: new ( & create_instance_params. configuration . credential ) ;
4259
@@ -79,7 +96,7 @@ impl ClientEntity {
7996 if let Some ( delay) = streaming. initial_retry_delay_ms {
8097 streaming_builder. initial_reconnect_delay ( Duration :: from_millis ( delay) ) ;
8198 }
82- streaming_builder. https_connector ( connector . clone ( ) ) ;
99+ streaming_builder. transport ( transport . clone ( ) ) ;
83100
84101 config_builder = config_builder. data_source ( & streaming_builder) ;
85102 } else if let Some ( polling) = create_instance_params. configuration . polling {
@@ -91,15 +108,15 @@ impl ClientEntity {
91108 if let Some ( delay) = polling. poll_interval_ms {
92109 polling_builder. poll_interval ( Duration :: from_millis ( delay) ) ;
93110 }
94- polling_builder. https_connector ( connector . clone ( ) ) ;
111+ polling_builder. transport ( transport . clone ( ) ) ;
95112
96113 config_builder = config_builder. data_source ( & polling_builder) ;
97114 } else {
98115 // If we didn't specify streaming or polling, we fall back to basic streaming. The only
99- // customization we provide is the https connector to support testing multiple
100- // connectors .
116+ // customization we provide is the transport to support testing multiple
117+ // transport implementations .
101118 let mut streaming_builder = StreamingDataSourceBuilder :: new ( ) ;
102- streaming_builder. https_connector ( connector . clone ( ) ) ;
119+ streaming_builder. transport ( transport . clone ( ) ) ;
103120 config_builder = config_builder. data_source ( & streaming_builder) ;
104121 }
105122
@@ -113,6 +130,7 @@ impl ClientEntity {
113130 processor_builder. capacity ( capacity) ;
114131 }
115132 processor_builder. all_attributes_private ( events. all_attributes_private ) ;
133+ processor_builder. compress_events ( false ) ;
116134 if let Some ( e) = events. enable_gzip {
117135 processor_builder. compress_events ( e) ;
118136 }
@@ -124,7 +142,7 @@ impl ClientEntity {
124142 if let Some ( attributes) = events. global_private_attributes {
125143 processor_builder. private_attributes ( attributes) ;
126144 }
127- processor_builder. https_connector ( connector . clone ( ) ) ;
145+ processor_builder. transport ( transport ) ;
128146 processor_builder. omit_anonymous_contexts ( events. omit_anonymous_contexts ) ;
129147
130148 config_builder. event_processor ( & processor_builder)
@@ -214,14 +232,17 @@ impl ClientEntity {
214232 ContextResponse :: from ( Self :: context_convert ( params) ) ,
215233 ) ) )
216234 }
235+ #[ cfg( any( feature = "crypto-aws-lc-rs" , feature = "crypto-openssl" ) ) ]
217236 "secureModeHash" => {
218237 let params = command
219238 . secure_mode_hash
220239 . ok_or ( "secureModeHash params should be set" ) ?;
240+ let hash = self
241+ . client
242+ . secure_mode_hash ( & params. context )
243+ . map_err ( |e| e. to_string ( ) ) ?;
221244 Ok ( Some ( CommandResponse :: SecureModeHash (
222- SecureModeHashResponse {
223- result : self . client . secure_mode_hash ( & params. context ) ,
224- } ,
245+ SecureModeHashResponse { result : hash } ,
225246 ) ) )
226247 }
227248 "migrationVariation" => {
@@ -551,7 +572,7 @@ impl ClientEntity {
551572 }
552573
553574 if params. client_side_only {
554- config. client_side_only ( ) ;
575+ config. flag_filter ( FlagFilter :: CLIENT ) ;
555576 }
556577
557578 if params. details_only_for_tracked_flags {
0 commit comments