Skip to content

Commit

Permalink
Do not call worker enumeration for invokes
Browse files Browse the repository at this point in the history
  • Loading branch information
vigoo committed Dec 9, 2024
1 parent b20dcf0 commit 3e1b37f
Showing 1 changed file with 9 additions and 33 deletions.
42 changes: 9 additions & 33 deletions golem-cli/src/service/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,40 +216,16 @@ async fn resolve_worker_component_version<ProjectContext: Send + Sync>(
components: &(dyn ComponentService<ProjectContext = ProjectContext> + Send + Sync),
worker_urn: WorkerUrn,
) -> Result<Option<Component>, GolemError> {
let TargetWorkerId {
component_id,
worker_name,
} = worker_urn.id;

if let Some(worker_name) = worker_name {
let component_urn = ComponentUrn { id: component_id };

let worker_meta = client
.find_metadata(
component_urn.clone(),
Some(WorkerFilter::Name(WorkerNameFilter {
comparator: StringFilterComparator::Equal,
value: worker_name,
})),
None,
Some(2),
Some(true),
)
.await?;
if worker_urn.id.worker_name.is_some() {
let component_urn = ComponentUrn {
id: worker_urn.id.component_id.clone(),
};

if worker_meta.workers.len() > 1 {
Err(GolemError(
"Multiple workers with the same name".to_string(),
))
} else if let Some(worker) = worker_meta.workers.first() {
Ok(Some(
components
.get_metadata(&component_urn, worker.component_version)
.await?,
))
} else {
Ok(None)
}
let worker_metadata = client.get_metadata(worker_urn).await?;
let component_metadata = components
.get_metadata(&component_urn, worker_metadata.component_version)
.await?;
Ok(Some(component_metadata))
} else {
Ok(None)
}
Expand Down

0 comments on commit 3e1b37f

Please sign in to comment.