ningyougang commented on PR #170:
URL:
https://github.com/apache/openwhisk-runtime-go/pull/170#issuecomment-1193615048
The steps of test `Support sequence action`
* Write split.go and sort.go
```go
[root@nccddev130026 ~]# cat ~/split.go
package main
import (
"strings"
)
// Main is the function implementing the action
func Main(obj map[string]interface{}) []interface{} {
payload, ok := obj["payload"].(string)
if !ok {
payload = "aaaa\nbbbb\ncccc"
}
separator, ok := obj["separator"].(string)
if !ok {
separator = "\n"
}
stringSlice := strings.Split(payload, separator)
output := make([]interface{}, len(stringSlice))
for i, v := range stringSlice {
output[i] = v
}
return output
}
[root@nccddev130026 ~]# cat ~/sort.go
package main
import (
"fmt"
"sort"
)
// Main is the function implementing the action
func Main(event []interface{}) []interface{} {
input := make([]string, len(event))
for i, v := range event {
input[i] = fmt.Sprint(v)
}
sort.Strings(input)
output := make([]interface{}, len(event))
for i, v := range input {
output[i] = v
}
return output
}
```
* Create sequence action and invoke it (go1.17 and go1.18 both tested,
worked well)
```shell
wsk -i action create /whisk.system/utils/split-go --kind go:1.17 ~/split.go
wsk -i action create /whisk.system/utils/sort-go --kind go:1.17 ~/sort.go
wsk -i action create mySequence-go --sequence
/whisk.system/utils/split-go,/whisk.system/utils/sort-go
wsk -i action invoke --result mySequence-go --param payload
"dddd\nbbbb\ncccc" -r -v
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]