openwhisk-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [openwhisk-runtime-rust] rabbah commented on a change in pull request #16: update readme with usage instructions
Date Wed, 02 Oct 2019 13:38:09 GMT
rabbah commented on a change in pull request #16: update readme with usage instructions
URL: https://github.com/apache/openwhisk-runtime-rust/pull/16#discussion_r330553071
 
 

 ##########
 File path: README.md
 ##########
 @@ -16,10 +16,74 @@
 # limitations under the License.
 #
 -->
-# openwhisk-runtime-rust
-
-Work in Progress... It will be awesome!
+# Apache OpenWhisk Runtime for Rust
 
 [![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)
 [![Build Status](https://travis-ci.org/apache/openwhisk-runtime-rust.svg?branch=master)](https://travis-ci.org/apache/openwhisk-runtime-rust)
 
+### Give it a try today
+To use as a docker action
+
+```
+wsk action update myAction my_action.rs --docker openwhisk/actionloop-rust-v1.34
+```
+
+The file `my_action.rs` looks like:
+
+```
+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 {
+    body: String,
+}
+
+fn stranger() -> String {
+    "stranger".to_string()
+}
+
+pub fn main(args: Value) -> Result<Value, Error> {
+    let input: Input = serde_json::from_value(args)?;
+    let output = Output {
+        body: format!("Hello, {}", input.name),
+    };
+    serde_json::to_value(output)
+}
+```
+
+The action is mainly composed by a `main` function that accepts a json serde Value as input
and returns a Result including a json serde Value.
+
+### Managing dependencies
+
+if your action needs external dependencies, you need to provide a zip file including your
source and your cargo file with all your dependencies. The folder structure is the following:
 
 Review comment:
   ```suggestion
   If your action needs external dependencies, you need to provide a zip file including your
source and your cargo file with all your dependencies. The folder structure is the following:
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message