jpkessle commented on a change in pull request #3202: Support action 
continuations in the controller
URL: 
https://github.com/apache/incubator-openwhisk/pull/3202#discussion_r163055566
 
 

 ##########
 File path: docs/compositions.md
 ##########
 @@ -0,0 +1,144 @@
+# Action compositions
+
+Action compositions make it possible to dynamically build and invoke a series 
of actions. Action compositions are similar to sequences. However, whereas the 
components of a sequence must be specified before invoking the sequence, 
components of a composition can be decided as the composition is running.
+
+## Example
+
+Suppose we define an _increment_ action:
+
+```
+$ cat > increment.js
+function main({ value }) { return { value: value + 1 } }
+^D
+
+$ wsk action create increment increment.js
+```
+
+We can use this _increment_ action in a composition as follows:
+
+```
+$ cat > composition.js
+function main(params) {
+    switch (params.$step || 0) {
+        case 0: delete params.$step; return { params, action: 'increment', 
state: { $step: 1 } }
+        case 1: delete params.$step; return { params, action: 'increment', 
state: { $step: 2 } }
+        case 2: delete params.$step; return { params }
+    }
+}
+^D
+
+$ wsk action create composition composition.js -a conductor true
+```
+
+The key to making this action a composition is the _conductor_ annotation, 
which we discuss in the next section.
+
+This example composition executes two _increment_ actions in a sequence:
+
+```
+$ wsk action invoke composition -br -p value 3
+{
+    "value": 5
+}
+```
+
+In essence, this composition defines a program with three steps:
+
+- step 0: invoke increment on the input dictionary,
+- step 1: invoke increment on the output dictionary from step 1,
+- step 2: return the output dictionary from step 2.
+
+## Conductor Actions
+
+An action composition is driven by a _conductor action_. A _conductor action_, 
or in short a _conductor_,  is an action with a _conductor_ annotation. The 
value of the annotation is irrelevant.
+
+Because a conductor action is an action, it has all the attributes of an 
action (e.g., name, namespace, default parameters, limits...) and it can be 
managed as such, for instance using the `wsk action` CLI commands. It can be 
part of a package. It can be a web action. And so on.
 
 Review comment:
   Because a _conductor_ Action is an Action, it retains all of the attributes 
of an Action (e.g., name, namespace, default parameters, limits...), and it can 
be managed as such. For instance, using the `wsk action` CLI commands. It can 
be part of a package or be a web action and so on.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to