Skip to content
Open
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
42 changes: 28 additions & 14 deletions lib/saluki-core/src/topology/blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,8 @@ impl TopologyBuildState {
let identity = self.component_identity(ComponentType::Source, &component_id);
builder.specify_bounds(&mut self.component_registry.bounds_builder(&identity));

self.recalculate_bounds();

let _ = self.sources.insert(component_id, Box::new(builder));
self.recalculate_bounds();

Ok(())
}
Expand All @@ -621,9 +620,8 @@ impl TopologyBuildState {
let identity = self.component_identity(ComponentType::Relay, &component_id);
builder.specify_bounds(&mut self.component_registry.bounds_builder(&identity));

self.recalculate_bounds();

let _ = self.relays.insert(component_id, Box::new(builder));
self.recalculate_bounds();

Ok(())
}
Expand All @@ -641,9 +639,8 @@ impl TopologyBuildState {
let identity = self.component_identity(ComponentType::Decoder, &component_id);
builder.specify_bounds(&mut self.component_registry.bounds_builder(&identity));

self.recalculate_bounds();

let _ = self.decoders.insert(component_id, Box::new(builder));
self.recalculate_bounds();

Ok(())
}
Expand All @@ -661,9 +658,8 @@ impl TopologyBuildState {
let identity = self.component_identity(ComponentType::Transform, &component_id);
builder.specify_bounds(&mut self.component_registry.bounds_builder(&identity));

self.recalculate_bounds();

let _ = self.transforms.insert(component_id, Box::new(builder));
self.recalculate_bounds();

Ok(())
}
Expand All @@ -681,9 +677,8 @@ impl TopologyBuildState {
let identity = self.component_identity(ComponentType::Destination, &component_id);
builder.specify_bounds(&mut self.component_registry.bounds_builder(&identity));

self.recalculate_bounds();

let _ = self.destinations.insert(component_id, Box::new(builder));
self.recalculate_bounds();

Ok(())
}
Expand All @@ -701,9 +696,8 @@ impl TopologyBuildState {
let identity = self.component_identity(ComponentType::Encoder, &component_id);
builder.specify_bounds(&mut self.component_registry.bounds_builder(&identity));

self.recalculate_bounds();

let _ = self.encoders.insert(component_id, Box::new(builder));
self.recalculate_bounds();

Ok(())
}
Expand All @@ -721,9 +715,8 @@ impl TopologyBuildState {
let identity = self.component_identity(ComponentType::Forwarder, &component_id);
builder.specify_bounds(&mut self.component_registry.bounds_builder(&identity));

self.recalculate_bounds();

let _ = self.forwarders.insert(component_id, Box::new(builder));
self.recalculate_bounds();

Ok(())
}
Expand Down Expand Up @@ -2230,6 +2223,27 @@ mod tests {
);
}

#[test]
fn recalculate_bounds_includes_last_added_component() {
let blueprint = blueprint_with_components();

let (interconnect_capacity, bounds) = {
let guard = blueprint.build_state.lock().expect("topology blueprint mutex poisoned");
let state = guard.as_ref().expect("topology blueprint already initialized");
(state.interconnect_capacity.get(), state.component_registry.as_bounds())
};

// `blueprint_with_components` registers one source, one transform, and one destination.
let expected_min = (interconnect_capacity * 2) * std::mem::size_of::<EventsBuffer>();
let max_in_flight = (2 * interconnect_capacity) + 1 + 1;
let per_buffer =
std::mem::size_of::<EventsBuffer>() + (std::mem::size_of::<Event>() * DEFAULT_EVENTS_BUFFER_CAPACITY);
let expected_firm = expected_min + (max_in_flight * per_buffer);

assert_eq!(bounds.total_minimum_required_bytes(), expected_min);
assert_eq!(bounds.total_firm_limit_bytes(), expected_firm);
}

#[test]
fn worker_pool_configuration_defaults_to_dedicated() {
let blueprint = blueprint_with_components();
Expand Down
66 changes: 39 additions & 27 deletions lib/saluki-io/src/net/client/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,38 +385,50 @@ impl HttpClientBuilder {
None => self.tls_builder.build()?,
};
let connector = self.connector_builder.build(tls_config)?;
let tls_handshake_timeout = connector.tls_handshake_timeout();
// The inner connector verifies HTTPS proxies; this separate config verifies destinations through CONNECT.
// Keep native roots and verification enabled here even if the inner connector uses an insecure local config.
let mut proxy_tls_config = ClientTLSConfigBuilder::new()
.with_root_cert_store(load_platform_root_certificates_inner()?)
.build()?;
if http_protocol == HttpProtocol::Http2 {
// The proxy connector can't report a negotiated `h2`. Advertise `h2` only when the client requires it.
proxy_tls_config.alpn_protocols = http_protocol_alpns(http_protocol);
}
let mut proxy_connector = hyper_http_proxy::ProxyConnector::unsecured(connector);
proxy_connector.set_tls(Some(TlsConnector::from(Arc::new(proxy_tls_config))));
// A zero timeout means the handshake deadline is disabled, matching `HttpsCapableConnector`'s own
// handling of `Duration::ZERO` for direct connections.
let proxy_tls_handshake_timeout = (!tls_handshake_timeout.is_zero()).then_some(tls_handshake_timeout);
proxy_connector.set_tls_handshake_timeout(proxy_tls_handshake_timeout);
if let Some(proxies) = &self.proxies {
for proxy in proxies {
proxy_connector.add_proxy(proxy.to_owned());
}
}
let mut hyper_builder = self.hyper_builder;
if http_protocol == HttpProtocol::Http2 {
hyper_builder.http2_only(true);
}
let client = hyper_builder.build(proxy_connector);

let inner = ServiceBuilder::new()
.option_layer(self.request_timeout.map(TimeoutLayer::new))
.option_layer(self.endpoint_telemetry)
.service(client.map_err(BoxError::from))
.boxed_clone();
let has_proxies = self.proxies.as_ref().is_some_and(|proxies| !proxies.is_empty());
let inner = if has_proxies {
let tls_handshake_timeout = connector.tls_handshake_timeout();
// The inner connector verifies HTTPS proxies; this separate config verifies destinations through CONNECT.
// Keep native roots and verification enabled here even if the inner connector uses an insecure local
// config.
let mut proxy_tls_config = ClientTLSConfigBuilder::new()
.with_root_cert_store(load_platform_root_certificates_inner()?)
.build()?;
if http_protocol == HttpProtocol::Http2 {
// The proxy connector can't report a negotiated `h2`. Advertise `h2` only when the client requires it.
proxy_tls_config.alpn_protocols = http_protocol_alpns(http_protocol);
}
let mut proxy_connector = hyper_http_proxy::ProxyConnector::unsecured(connector);
proxy_connector.set_tls(Some(TlsConnector::from(Arc::new(proxy_tls_config))));
// A zero timeout means the handshake deadline is disabled, matching `HttpsCapableConnector`'s own
// handling of `Duration::ZERO` for direct connections.
let proxy_tls_handshake_timeout = (!tls_handshake_timeout.is_zero()).then_some(tls_handshake_timeout);
proxy_connector.set_tls_handshake_timeout(proxy_tls_handshake_timeout);
if let Some(proxies) = &self.proxies {
for proxy in proxies {
proxy_connector.add_proxy(proxy.to_owned());
}
}

let client = hyper_builder.build(proxy_connector);
ServiceBuilder::new()
.option_layer(self.request_timeout.map(TimeoutLayer::new))
.option_layer(self.endpoint_telemetry)
.service(client.map_err(BoxError::from))
.boxed_clone()
} else {
let client = hyper_builder.build(connector);
ServiceBuilder::new()
.option_layer(self.request_timeout.map(TimeoutLayer::new))
.option_layer(self.endpoint_telemetry)
.service(client.map_err(BoxError::from))
.boxed_clone()
};

Ok(HttpClient { inner })
}
Expand Down
Loading