Skip to content

Commit

Permalink
Simple workflow: use better callback names
Browse files Browse the repository at this point in the history
  • Loading branch information
ccicconetti committed Sep 11, 2023
1 parent fef7053 commit 3d0deef
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 16 deletions.
5 changes: 1 addition & 4 deletions examples/simple_workflow_http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@ target/debug/edgeless_cli function build examples/simple_workflow_http/double/fu
target/debug/edgeless_cli function build examples/simple_workflow_http/incr/function.json
```


Then, you can request the controller to start the workflow:

```bash
ID=$(target/debug/edgeless_cli workflow start examples/simple_workflow_http/workflow.json)
target/debug/edgeless_cli workflow start examples/simple_workflow_http/workflow.json
```

Now `$ID` contains the workflow identifier assigned by the controller.

In a shell open a TCP socket at port 10000 that plays the role of the external sink:

```bash
Expand Down
2 changes: 1 addition & 1 deletion examples/simple_workflow_http/double/function.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"version": "0.1",
"build": "Cargo.toml",
"output_callbacks": [
"cb_success"
"result"
]
}
2 changes: 1 addition & 1 deletion examples/simple_workflow_http/double/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ impl Edgefunction for DoubleFun {
log::info!("double: called with '{}'", encoded_message);

if let Ok(n) = encoded_message.parse::<i32>() {
cast_alias("cb_success", format!("{}", 2 * n).as_str());
cast_alias("result", format!("{}", 2 * n).as_str());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"version": "0.1",
"build": "Cargo.toml",
"output_callbacks": [
"cb_success"
"parsed_value"
]
}
2 changes: 1 addition & 1 deletion examples/simple_workflow_http/http_read_number/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl Edgefunction for HttpReadNumberFun {
if let Some(body) = req.body {
if let Ok(content) = String::from_utf8(body) {
if let Ok(_) = content.parse::<i32>() {
cast_alias("cb_success", &content);
cast_alias("parsed_value", &content);
(200, None)
} else {
(400, Some(Vec::<u8>::from("body does not contain an integer")))
Expand Down
2 changes: 1 addition & 1 deletion examples/simple_workflow_http/incr/function.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"version": "0.1",
"build": "Cargo.toml",
"output_callbacks": [
"cb_success"
"result"
]
}
2 changes: 1 addition & 1 deletion examples/simple_workflow_http/incr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ impl Edgefunction for IncrFun {
log::info!("incr: called with '{}'", encoded_message);

if let Ok(n) = encoded_message.parse::<i32>() {
cast_alias("cb_success", format!("{}", n + 1).as_str());
cast_alias("result", format!("{}", n + 1).as_str());
}
}

Expand Down
12 changes: 6 additions & 6 deletions examples/simple_workflow_http/workflow.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"version": "0.1",
"include_code_file": "./http_read_number/http_read_number.wasm",
"output_callbacks": [
"cb_success"
"parsed_value"
]
},
"output_callback_definitions": {
"cb_success": "incr"
"parsed_value": "incr"
},
"annotations": {}
},
Expand All @@ -25,11 +25,11 @@
"version": "0.1",
"include_code_file": "./incr/incr.wasm",
"output_callbacks": [
"cb_success"
"result"
]
},
"output_callback_definitions": {
"cb_success": "double"
"result": "double"
},
"annotations": {}
},
Expand All @@ -41,11 +41,11 @@
"version": "0.1",
"include_code_file": "./double/double.wasm",
"output_callbacks": [
"cb_success"
"result"
]
},
"output_callback_definitions": {
"cb_success": "external_sink"
"result": "external_sink"
},
"annotations": {}
},
Expand Down

0 comments on commit 3d0deef

Please sign in to comment.