Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit d552b7d

Browse files
authored
Follow refactorings removing multi-return value support in Golem (#271)
* Follow refactorings removing multi-return value support in Golem * Published deps * Fix
1 parent 8a82a1e commit d552b7d

File tree

12 files changed

+330
-268
lines changed

12 files changed

+330
-268
lines changed

Cargo.lock

Lines changed: 210 additions & 98 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,24 @@ license-file = "LICENSE"
1111
[workspace.dependencies]
1212

1313
# Golem dep
14-
golem-client = "=1.3.0-dev.6"
15-
golem-common = "=1.3.0-dev.6"
16-
golem-rdbms = "=0.0.2"
17-
golem-rib = "=1.3.0-dev.6"
18-
golem-rib-repl = "=1.3.0-dev.6"
19-
golem-service-base = "=1.3.0-dev.6"
20-
golem-wasm-ast = { version = "=1.3.0-dev.6", default-features = false, features = [
14+
golem-client = "=1.3.0-dev.8"
15+
golem-common = "=1.3.0-dev.8"
16+
golem-rib = "=1.3.0-dev.8"
17+
golem-rib-repl = "=1.3.0-dev.8"
18+
golem-service-base = "=1.3.0-dev.8"
19+
golem-wasm-ast = { version = "=1.3.0-dev.8", default-features = false, features = [
2120
"analysis",
2221
"wave",
2322
] }
24-
golem-wasm-rpc = { version = "=1.3.0-dev.6", default-features = false, features = [
23+
golem-wasm-rpc = { version = "=1.3.0-dev.8", default-features = false, features = [
2524
"host",
2625
] }
27-
golem-wit = "=1.3.0-dev.2"
26+
27+
golem-rdbms = "=0.0.2"
28+
golem-wit = "=1.3.0-dev.3"
2829

2930
# Golem cloud deps
30-
golem-cloud-client = "=1.3.0-dev.6"
31+
golem-cloud-client = "=1.3.0-dev.8"
3132

3233
# External deps
3334
anyhow = "1.0.97"
@@ -48,7 +49,7 @@ clap-verbosity-flag = { version = "3.0.2", features = ["tracing"] }
4849
clap_complete = "4.5.45"
4950
cli-table = "0.4.9"
5051
colored = "3.0.0"
51-
darling = "=0.20.10"
52+
darling = "0.20.11"
5253
dirs = "6.0.0"
5354
dir-diff = "0.3.3"
5455
envsubst = "0.2.1"
@@ -129,13 +130,13 @@ wit-encoder = "0.228"
129130
wit-parser = "0.228"
130131

131132
[patch.crates-io]
132-
golem-client = { git = "https://github.com/golemcloud/golem.git", tag = "v1.3.0-dev.6" }
133-
golem-common = { git = "https://github.com/golemcloud/golem.git", tag = "v1.3.0-dev.6" }
134-
golem-rib = { git = "https://github.com/golemcloud/golem.git", tag = "v1.3.0-dev.6" }
135-
golem-rib-repl = { git = "https://github.com/golemcloud/golem.git", tag = "v1.3.0-dev.6" }
136-
golem-service-base = { git = "https://github.com/golemcloud/golem.git", tag = "v1.3.0-dev.6" }
137-
golem-wasm-ast = { git = "https://github.com/golemcloud/golem.git", tag = "v1.3.0-dev.6" }
138-
golem-wasm-rpc = { git = "https://github.com/golemcloud/golem.git", tag = "v1.3.0-dev.6" }
133+
golem-client = { git = "https://github.com/golemcloud/golem.git", tag = "v1.3.0-dev.8" }
134+
golem-common = { git = "https://github.com/golemcloud/golem.git", tag = "v1.3.0-dev.8" }
135+
golem-rib = { git = "https://github.com/golemcloud/golem.git", tag = "v1.3.0-dev.8" }
136+
golem-rib-repl = { git = "https://github.com/golemcloud/golem.git", tag = "v1.3.0-dev.8" }
137+
golem-service-base = { git = "https://github.com/golemcloud/golem.git", tag = "v1.3.0-dev.8" }
138+
golem-wasm-ast = { git = "https://github.com/golemcloud/golem.git", tag = "v1.3.0-dev.8" }
139+
golem-wasm-rpc = { git = "https://github.com/golemcloud/golem.git", tag = "v1.3.0-dev.8" }
139140

140141
redis-protocol = { git = "https://github.com/golemcloud/redis-protocol.rs.git", branch = "unpin-cookie-factory" }
141142
wasmtime = { git = "https://github.com/golemcloud/wasmtime.git", branch = "golem-wasmtime-v32.0.0" }

golem-cli/src/command_handler/rib_repl.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ impl RibReplHandler {
9393
printer: None,
9494
component_source: None,
9595
prompt: None,
96+
command_registry: None,
9697
})
9798
.await?;
9899

@@ -136,7 +137,7 @@ impl WorkerFunctionInvoke for RibReplHandler {
136137
worker_name: Option<String>,
137138
function_name: &str,
138139
args: Vec<ValueAndType>,
139-
) -> anyhow::Result<ValueAndType> {
140+
) -> anyhow::Result<Option<ValueAndType>> {
140141
let worker_name = worker_name.map(WorkerName::from);
141142

142143
let component = self
@@ -176,7 +177,8 @@ impl WorkerFunctionInvoke for RibReplHandler {
176177

177178
result
178179
.result
179-
.try_into()
180+
.map(|tav| tav.try_into())
181+
.transpose()
180182
.map_err(|err| anyhow!("Failed to convert result: {}", err))
181183
}
182184
}

golem-cli/src/model/component.rs

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ fn render_non_wave_compatible_exported_function(
349349
.join(", ");
350350

351351
let results = f
352-
.results
352+
.result
353353
.iter()
354354
.map(|res| render_type(&res.typ))
355355
.collect::<Vec<String>>();
@@ -419,7 +419,7 @@ pub fn function_result_types<'t>(
419419
) -> anyhow::Result<Vec<&'t AnalysedType>> {
420420
let (func, _) = resolve_function(component, function)?;
421421

422-
Ok(func.results.iter().map(|r| &r.typ).collect())
422+
Ok(func.result.iter().map(|r| &r.typ).collect())
423423
}
424424

425425
pub fn function_params_types<'t>(
@@ -455,10 +455,9 @@ mod tests {
455455
let f = AnalysedFunction {
456456
name: "n".to_string(),
457457
parameters: vec![],
458-
results: vec![AnalysedFunctionResult {
459-
name: None,
458+
result: Some(AnalysedFunctionResult {
460459
typ: handle(AnalysedResourceId(1), AnalysedResourceMode::Borrowed),
461-
}],
460+
}),
462461
};
463462
let repr = render_exported_function(None, &f, true);
464463

@@ -470,7 +469,7 @@ mod tests {
470469
let f = AnalysedFunction {
471470
name: "abc".to_string(),
472471
parameters: vec![],
473-
results: vec![],
472+
result: None,
474473
};
475474

476475
let repr = render_exported_function(None, &f, true);
@@ -486,7 +485,7 @@ mod tests {
486485
name: "n".to_string(),
487486
typ: handle(AnalysedResourceId(1), AnalysedResourceMode::Owned),
488487
}],
489-
results: vec![],
488+
result: None,
490489
};
491490

492491
let repr = render_exported_function(None, &f, true);
@@ -499,10 +498,7 @@ mod tests {
499498
let f = AnalysedFunction {
500499
name: "abc".to_string(),
501500
parameters: vec![],
502-
results: vec![AnalysedFunctionResult {
503-
name: None,
504-
typ: bool(),
505-
}],
501+
result: Some(AnalysedFunctionResult { typ: bool() }),
506502
};
507503

508504
let repr = render_exported_function(None, &f, true);
@@ -515,10 +511,9 @@ mod tests {
515511
let f = AnalysedFunction {
516512
name: "abc".to_string(),
517513
parameters: vec![],
518-
results: vec![AnalysedFunctionResult {
519-
name: None,
514+
result: Some(AnalysedFunctionResult {
520515
typ: handle(AnalysedResourceId(1), AnalysedResourceMode::Owned),
521-
}],
516+
}),
522517
};
523518

524519
let repr = render_exported_function(None, &f, true);
@@ -540,21 +535,14 @@ mod tests {
540535
typ: bool(),
541536
},
542537
],
543-
results: vec![
544-
AnalysedFunctionResult {
545-
name: Some("r1".to_string()),
546-
typ: bool(),
547-
},
548-
AnalysedFunctionResult {
549-
name: None,
550-
typ: bool(),
551-
},
552-
],
538+
result: Some(AnalysedFunctionResult {
539+
typ: tuple(vec![bool(), bool()]),
540+
}),
553541
};
554542

555543
let repr = render_exported_function(None, &f, true);
556544

557-
assert_eq!(repr, "abc(n1: bool, n2: bool) -> (bool, bool)")
545+
assert_eq!(repr, "abc(n1: bool, n2: bool) -> tuple<bool, bool>")
558546
}
559547

560548
#[test]
@@ -571,21 +559,14 @@ mod tests {
571559
typ: handle(AnalysedResourceId(1), AnalysedResourceMode::Owned),
572560
},
573561
],
574-
results: vec![
575-
AnalysedFunctionResult {
576-
name: Some("r1".to_string()),
577-
typ: bool(),
578-
},
579-
AnalysedFunctionResult {
580-
name: None,
581-
typ: bool(),
582-
},
583-
],
562+
result: Some(AnalysedFunctionResult {
563+
typ: tuple(vec![bool(), bool()]),
564+
}),
584565
};
585566

586567
let repr = render_exported_function(None, &f, true);
587568

588-
assert_eq!(repr, "abc(n1: bool, n2: handle<1>) -> (bool, bool)")
569+
assert_eq!(repr, "abc(n1: bool, n2: handle<1>) -> tuple<bool, bool>")
589570
}
590571

591572
fn ensure_same_export(typ: AnalysedType, expected: &str) {
@@ -595,24 +576,20 @@ mod tests {
595576
let wave_f = AnalysedFunction {
596577
name: "wn".to_string(),
597578
parameters: vec![],
598-
results: vec![AnalysedFunctionResult {
599-
name: None,
600-
typ: typ.clone(),
601-
}],
579+
result: Some(AnalysedFunctionResult { typ: typ.clone() }),
602580
};
603581
let wave_res = render_exported_function(None, &wave_f, true);
604582
assert_eq!(wave_res, expected_wave);
605583

606584
let custom_f = AnalysedFunction {
607585
name: "cn".to_string(),
608586
parameters: vec![],
609-
results: vec![AnalysedFunctionResult {
610-
name: None,
587+
result: Some(AnalysedFunctionResult {
611588
typ: tuple(vec![
612589
handle(AnalysedResourceId(1), AnalysedResourceMode::Owned),
613590
typ,
614591
]),
615-
}],
592+
}),
616593
};
617594
let custom_res = render_exported_function(None, &custom_f, true);
618595
assert_eq!(custom_res, expected_custom);

golem-cli/src/model/invoke_result_view.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl InvokeResultView {
4747

4848
Self {
4949
idempotency_key: idempotency_key.0,
50-
result_json: Some(result.result),
50+
result_json: result.result,
5151
result_wave: wave,
5252
}
5353
}
@@ -61,23 +61,11 @@ impl InvokeResultView {
6161
}
6262

6363
fn try_parse_wave(
64-
result: &TypeAnnotatedValue,
64+
result: &Option<TypeAnnotatedValue>,
6565
component: &Component,
6666
function: &str,
6767
) -> anyhow::Result<Vec<String>> {
68-
let results = match result {
69-
TypeAnnotatedValue::Tuple(tuple) => tuple
70-
.value
71-
.iter()
72-
.map(|t| t.clone().type_annotated_value.unwrap())
73-
.collect::<Vec<_>>(),
74-
// TODO: need to support multi-result case when it's a Record
75-
_ => {
76-
bail!("Can't parse InvokeResult - tuple expected.");
77-
}
78-
};
79-
80-
// TODO: we don't need this, as the result is always a TypeAnnotatedValue
68+
let results: Vec<_> = result.iter().cloned().collect();
8169
let result_types = function_result_types(component, function)?;
8270

8371
if results.len() != result_types.len() {

golem-cli/src/model/text/worker.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,11 @@ impl TextView for PublicOplogEntry {
358358
));
359359
logln(format!(
360360
"{pad}result: {}",
361-
value_to_string(&params.response)
361+
params
362+
.response
363+
.as_ref()
364+
.map(value_to_string)
365+
.unwrap_or_else(|| "()".to_string())
362366
));
363367
}
364368
PublicOplogEntry::Suspend(params) => {

golem-cli/src/model/wave.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ pub fn type_wave_compatible(typ: &AnalysedType) -> bool {
6464

6565
pub fn function_wave_compatible(func: &AnalysedFunction) -> bool {
6666
func.parameters.iter().all(|p| type_wave_compatible(&p.typ))
67-
&& func.results.iter().all(|r| type_wave_compatible(&r.typ))
67+
&& func.result.iter().all(|r| type_wave_compatible(&r.typ))
6868
}

0 commit comments

Comments
 (0)