An OpenWhisk runtime is a Docker container that runs a web server on port 8080 that executes the requested code.

The web server needs to respond to two end points: /init and /run and runs on port 8080.

The /init end point

After starting the Docker container, the invoker will POST to /init with the following payload:

{ 
"value": {
"name" : "helloPHP",
"main" : "main",
"binary": false,
"code" : "<?php …",
}
}
nameThe name of the action
mainThe name of the function to be executed
binaryFlag indicating if code is plain text or a base64 encoded zip file
codeEither plain text source code or a base64 encoded zip file

 

This happens once per container creation. This end point returns a 200 status code on success. The payload doesn't matter and { "OK": true} is common.

The /run end point

To run the action, the invoker will POST to /run. This may happen multiple times, but never concurrently. The payload contains the arguments to be passed to the function to be executed. For example:

{ 
"value":
    { 
"name" : "Rob",
}
}

The end point will run the function and must return to the invoker, a JSON object. A successful invocation of the function will pass back the dictionary returned by the function that was executed.

  • No labels