Encapsulate external node source fields

This commit is contained in:
andrussal 2026-03-08 13:38:10 +01:00
parent 0ff1ae1904
commit 74290327a3
4 changed files with 17 additions and 7 deletions

View File

@ -44,7 +44,7 @@ impl Application for LbcExtEnv {
type FeedRuntime = <LbcEnv as Application>::FeedRuntime;
fn external_node_client(source: &ExternalNodeSource) -> Result<Self::NodeClient, DynError> {
let base_url = Url::parse(&source.endpoint)?;
let base_url = Url::parse(source.endpoint())?;
Ok(NodeHttpClient::from_urls(base_url, None))
}

View File

@ -71,11 +71,11 @@ impl<E: Application> ExternalProvider<E> for ApplicationExternalProvider {
.map(|source| {
E::external_node_client(source)
.map(|client| ExternalNode {
identity_hint: Some(source.label.clone()),
identity_hint: Some(source.label().to_string()),
client,
})
.map_err(|build_error| ExternalProviderError::Build {
source_label: source.label.clone(),
source_label: source.label().to_string(),
source: build_error,
})
})

View File

@ -49,8 +49,8 @@ impl AttachSource {
/// inventory.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ExternalNodeSource {
pub label: String,
pub endpoint: String,
label: String,
endpoint: String,
}
impl ExternalNodeSource {
@ -58,6 +58,16 @@ impl ExternalNodeSource {
pub fn new(label: String, endpoint: String) -> Self {
Self { label, endpoint }
}
#[must_use]
pub fn label(&self) -> &str {
&self.label
}
#[must_use]
pub fn endpoint(&self) -> &str {
&self.endpoint
}
}
/// Planned readiness strategy for mixed managed/attached/external sources.

View File

@ -35,8 +35,8 @@ pub fn build_external_client<E: LocalDeployerEnv>(
}
fn resolve_api_socket(source: &ExternalNodeSource) -> Result<std::net::SocketAddr, DynError> {
let source_label = source.label.clone();
let endpoint = source.endpoint.trim();
let source_label = source.label().to_string();
let endpoint = source.endpoint().trim();
if endpoint.is_empty() {
return Err(ExternalClientBuildError::EmptyEndpoint {
label: source_label,