| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Test make java runtime to support array result for sequence action (support array as input param)'s steps as below
[root@nccddev130026 ~]# cat ~/Split.java
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
public class Split {
public static JsonArray main(JsonObject args) {
String separator = "\n";
if (args.has("separator")) {
separator = args.getAsJsonPrimitive("separator").getAsString();
}
String payLoad = "aaaa\nbbbb\ncccc";
if (args.has("payload")) {
payLoad = args.getAsJsonPrimitive("payload").getAsString();
}
JsonArray jsonArray = new JsonArray();
String[] stringArray = payLoad.split(separator);
for(String element: stringArray) {
jsonArray.add(element);
}
return jsonArray;
}
}
[root@nccddev130026 ~]# cat ~/Sort.java
import com.google.gson.JsonArray;
public class Sort {
public static JsonArray main(JsonArray args) {
JsonArray newJsonArray = new JsonArray();
for(int i=args.size()-1;i>=0;i--) {
newJsonArray.add(args.get(i).getAsString());
}
return newJsonArray;
}
}
javac -classpath "/root/gson-2.9.0.jar" Split.java
jar cvf split.jar Split.class
wsk -i action create /whisk.system/utils/split-java split.jar --main Split --kind java:8
javac -classpath "/root/gson-2.9.0.jar" Sort.java
jar cvf sort.jar Sort.class
wsk -i action create /whisk.system/utils/sort-java sort.jar --main Sort --kind java:8
wsk -i action create mySequence-java --sequence /whisk.system/utils/split-java,/whisk.system/utils/sort-java
wsk -i action invoke --result mySequence-java --param payload "aaaa\nbbbb\ncccc" -r -v |
Sorry, something went wrong.
- JsonObject is good here - JsonArray is bad here
Support json array for input param
| if (!existMain) { | ||
| throw new NoSuchMethodException(mainMethodName); | ||
| } | ||
| mainMethod = m; |
There was a problem hiding this comment.
Because need to support array result, cannot instantiate mainMethod in /init step, should move this relative logic to /run logic due to input param/out result can be JsonObject or JsonArray
Sorry, something went wrong.
| case "#bogus" => | ||
| s"$errPrefix java.lang.NoSuchMethodException: example.HelloWhisk.bogus(com.google.gson.JsonObject)" | ||
| case _ => s"$errPrefix java.lang.NoSuchMethodException: example.HelloWhisk.main(com.google.gson.JsonObject)" | ||
| case _ => s"$errPrefix java.lang.NoSuchMethodException" |
There was a problem hiding this comment.
Due to https://github.com/apache/openwhisk-runtime-java/pull/140/files#r939487201, need to change test case here for a small change as above.
Sorry, something went wrong.
|
|
||
| # select the builder to use | ||
| ARG GO_PROXY_BUILD_FROM=release | ||
| ARG GO_PROXY_BUILD_FROM=source |
There was a problem hiding this comment.
@style95 seems change GO_PROXY_BUILD_FROM to source is not better, but in order to support array result, must use go runtime's upstream master code.
Can we release a new version for go runtime? e.g. https://github.com/apache/openwhisk-runtime-java/blob/master/core/java8actionloop/Dockerfile#L29
Sorry, something went wrong.
There was a problem hiding this comment.
We could do a wave of runtime releases, starting with the go runtime. Would be reasonable to plan to get the go runtime released this week (takes 72 hours for the vote).
Sorry, something went wrong.
There was a problem hiding this comment.
@dgrove-oss , due to go runtime : 1.20.0 is released, i have updated all runtime prs(support array result)'s Dockerfile to apply this.
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Depend on below prs:
Support array result for common action and sequence action openwhisk#5290
Support array result include sequence action openwhisk-runtime-go#170
Support array result