You can use this INFRA ticket [1] as template to open a new issue to setup
rust Github repo

[1] https://issues.apache.org/jira/browse/INFRA-16770


On Thu, Mar 7, 2019 at 6:55 AM Carlos Santana <[email protected]> wrote:

> Hi Michele
>
>    Thanks for all the work on helping on this I know you are very busy +1
>
> I wanted to discuss the main method signature and open a github issue but
> issues are not enable in the rust repo [1]
>
> Did you open an INFRA ticket for infra people to configure and enable
> Github Issues? Please share the link I want ping them on Slack
>
> I was trying to debate on the usage of HashMap vs. jsonValue for the main
> handler method
>
> For example:
> fn handler_b(param: JsonValue) -> Result<JsonValue, JsonValue> {
>     let name = param["name"].as_str().unwrap();
>     if name == "" {
>         error!("Empty name in request");
>         return Err(serde_json::from_str(r#"{"message": "Empty name in
> param",}"#).unwrap());
>     } else {
>         println!("The name is {}", name);
>         let json_str = r#"{"body": "Hello World",}"#;
>         let res = serde_json::from_str(json_str).unwrap();
>         return Ok(res);
>     }
> }
>
> You can see the whole program in this gist [2] where I was playing with
> different Types
>
> I also checked on how AWS Rust handler signature looked
>
> [1] https://github.com/apache/incubator-openwhisk-runtime-rust
> [2]
> https://gist.github.com/csantanapr/50cae6a62b27192f32b1bd4801d8d7c4#file-rust_playground-rs-L40
> [3] https://aws.amazon.com/blogs/opensource/rust-runtime-for-aws-lambda/
>
>
>
> On Wed, Mar 6, 2019 at 5:58 AM Michele Sciabarra <[email protected]>
> wrote:
>
>> Thanks to the effort of Roberto Diaz who provided the actionloop in rust,
>> I built the Rust for OpenWhisk (ActionLoop powered, of course):
>>
>>
>> ```
>> $ wsk action create hello-rust src/lib.rs --docker
>> actionloop/actionloop-rust-v1.32
>> ok: created action hello-rust
>> $ wsk action invoke hello-rust -r
>> {
>>     "greeting": "Hello, stranger"
>> }
>> $ wsk action invoke hello-rust -r -p name Mike
>> {
>>     "greeting": "Hello, Mike"
>> }
>> ```
>>
>> This is the rust hello world (probably it can be written better I am an
>> absolute beginner in Rust...):
>>
>> ```
>> extern crate serde_json;
>>
>> use std::collections::HashMap;
>> use serde_json::Value;
>>
>> pub fn main(args: HashMap<String, Value>) -> HashMap<String, Value> {
>>     let name_opt = args.get("name");
>>     let name = if name_opt.is_some() {
>>         name_opt.unwrap().as_str().unwrap()
>>     } else {
>>         "stranger"
>>     };
>>     let mut out = HashMap::new();
>>     out.insert("greeting".to_string(), Value::String(format!("Hello, {}",
>> name)));
>>     out
>> }
>> ```
>>
>> Now we should add all the tests and provide the runtimes for integrating
>> into OpenWhisk...
>>
>> --
>>   Michele Sciabarra
>>   [email protected]
>>
>
>
> --
> Carlos Santana
> <[email protected]>
>


-- 
Carlos Santana
<[email protected]>

Reply via email to