Action invoke

OK, now we are ready to try out both newly created C and Go functions built in the previous sections. First, we will create an action using the wsk action create command starting with the C program:

$ wsk -i action create --docker chanwit/whisk_c whisk_c
ok: created action whisk_c

If things go correctly, wsk will tell us ok: created action. Next, we will invoke the action using the wsk action invoke command. The invoke command accepts one or more --param to pass parameters to the action. We can also pass --result to obtain the result synchronously. The result is, of course returned as JSON:

$ wsk -i action invoke --param key value --result whisk_c
{
"args": {
"key": "value"
},
"msg": "Hello from C program!"
}

We will try once more, this time with the Go program. First, create the action:

$ wsk -i action create --docker chanwit/whisk_go whisk_go
ok: created action whisk_go

Then, invoke the action using wsk action invoke:

$ wsk -i action invoke --param hello world --result whisk_go
{
"keys": [
"hello"
],
"message": "Hello from Go",
"values": [
"world"
]
}

As we have seen, we pack actions with Docker and it basically simplifies the whole process, starting with action preparation, creation, and invocation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset