FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Support array result include sequence action by ningyougang · Pull Request #39 · apache/openwhisk-runtime-rust · GitHub

Support array result include sequence action - #39

Merged
dgrove-oss merged 6 commits into
apache:masterfrom
ningyougang:support-array-result-include-sequence-action
Aug 15, 2022
Merged

dgrove-oss merged 6 commits into
apache:masterfrom
ningyougang:support-array-result-include-sequence-action

Conversation

ningyougang commented Jul 26, 2022 •
edited
Loading

Copy link
Copy Markdown
Contributor

Depend on below prs:

Copy link
Copy Markdown
Contributor Author

The rust supports sequence action by default, test steps as below

  • Write split.rs and sort.rs
extern crate serde_json;

use serde_derive::{Deserialize, Serialize};
use serde_json::{Error, Value};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
struct Input {
    #[serde(default = "stranger")]
    name: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
struct Output {
    greeting: String,
}

fn stranger() -> String {
    "stranger".to_string()
}

pub fn main(args: Value) -> Result<Value, Error> {
    // has no split, just return array, need to receive this value in next action(sort)
    let output = ["a", "b"];
    serde_json::to_value(output)
}

extern crate serde_json;

use serde_derive::{Deserialize, Serialize};
use serde_json::{Error, Value};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
struct Input {
    #[serde(default = "stranger")]
    name: String,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
struct Output {
    greeting: String,
}

fn stranger() -> String {
    "stranger".to_string()
}

pub fn main(args: Value) -> Result<Value, Error> {
    println!("param args is {}", args);

    let inputParam = args.as_array();
    println!("input param as array is {:?}", inputParam);

    let defaultOutput = ["finally-a", "finally-b"];
    match inputParam {
       None => serde_json::to_value(defaultOutput),
       Some(x) => serde_json::to_value(x),
    }
}
  • Create the action and invoke it
wsk -i action create /whisk.system/utils/split-rust --kind rust:1.34 ~/split.rs
wsk -i action create /whisk.system/utils/sort-rust --kind rust:1.34 ~/sort.rs
wsk -i action create mySequence-rust --sequence /whisk.system/utils/split-rust,/whisk.system/utils/sort-rust
wsk -i action invoke --result mySequence-rust -r -v

refer to: https://docs.serde.rs/serde_json/value/enum.Value.html

ningyougang force-pushed the support-array-result-include-sequence-action branch from dc405c3 to 20dc889 Compare August 8, 2022 07:32
Comment thread core/rust1.34/Dockerfile Outdated

# select the builder to use
ARG GO_PROXY_BUILD_FROM=release
ARG GO_PROXY_BUILD_FROM=source

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Need to change it to release due to apache/openwhisk-runtime-java#140 (comment)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Already changed to release

dgrove-oss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

dgrove-oss merged commit ebddcbd into apache:master Aug 15, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL