Hello all,
I am happy to announce I have closed my "TODO" list for Go Actions (and more)
providing unit tests in ScalaTests for the images I created.
It has been a long journey, but I recap what I accomplished so far:
1. developed a new "actionloop" protocol allowing for high performing binary
actions. It basically works reading json line by line in stdin, outputting in
fd3, with logs in stdout and stderr
2. The image "actionloop" implements a replacement of the python proxy in go
implementing this protocol. Note it works also for bash actions and generic
binaries. It is meant to replace (or complement) the docker skeleton
3. The image actionloop-golang supports action loops in GoLang. It accepts
either binaries or source actions in the format as in [1].
4. The image actionloop-swift supports action loops in Swift. It accepts either
binaries or source actions in the format as in [2]
5. As a side effect, I defined (and implemented) a "compiler" protocol for
using the runtimes as offline compilers to resolve the warm start problem.
Basically the images are also usable as standalone compilers. I used this
feature in tests, but it can be also leveraged, for example, in wskdeploy
Where is all this stuff?
1. Submitted PR#8 for complete handover of the actionloop (aka goproxy) to
incubator-openwhisk-runtime-go
2. Submitted PR#3 for handover of the swift support to
incubator-openwhisk-runtime-swift/
3. Submitter PR#47 including tests for the images actionloop,
actionloop-golang-v1.9, actionloop-swift-v4.1
The 3 PR should be reviewed and merged in order but I have checked they should
merge cleanly. Luckily they are not so big because the biggest one (the first)
has been already reviewed.
Now, I think I should focus on writing documentation for this stuff. I can
present it to the next interchange meeting.
[1] Example of Action in GoLang:
package action
import (
"encoding/json"
"fmt"
)
func Main(event json.RawMessage) (json.RawMessage, error) {
var obj map[string]interface{}
json.Unmarshal(event, &obj)
name, ok := obj["name"].(string)
if !ok {
name = "Stranger"
}
fmt.Printf("name=%s\n", name)
msg := map[string]string{"message": ("Hello, " + name + "!")}
return json.Marshal(msg)
}
[2] Example of Action in Swift:
func main(args: [String:Any]) -> [String:Any] {
if let name = args["name"] as? String {
print(name)
return [ "main" : "Hello \(name)!" ]
} else {
return [ "main" : "Hello swif4!" ]
}
}
--
Michele Sciabarra
[email protected]