tree: 8f90ec0df68d61068216a7ea98c3383f86619062 [path history] [tgz]
  1. content/
  2. lib/
  3. rendering-actions/
  4. .eslintrc.json
  5. eslintrc.js
  6. install
  7. microsling.js
  8. package-lock.json
  9. package.json
  10. README.md
serverless-microsling/README.md

Serverless Microsling

This prototype, created for the adaptTo() 2019 conference, implements a minimal Sling-like request processing pipeline in a serverless environment.

It reproduces (the basics of) the way Sling mechanism dynamically selects rendering pipeline components, using annotations on OpenWisk Actions to indicate what they can do, which resource types they process etc.

Its name comes from the historical microsling project from 2007, which served as the basis of today's Sling architecture and naming.

I don't have that much flight hours with JavaScript, please bear with me (or send patches) if you see ugly code in there.

Status

At commit 38794912, dynamic selection of renderers implemented by independent OpenWhisk functions (in the same namespace) works. See playing with the dynamic renderers selection below for how to experiment with that.

Prerequisite: Apache OpenWhisk

To run this prototype you'll need the OpenWhisk wsk command to be is setup as per the OpenWhisk docs.

A simple way to play with OpenWhisk is to use its standalone runnable jar. That's not released as I write this but you can download a build from Chetan's repository, which has been tested with this code.

Running the examples

Run the install script to install this code as an OpenWhisk action named microsling, along with a few rendering actions that demonstrate dynamic bindings of renderers.

The script outputs the URL at which the action is available:

Microsling is available at at https://openwhisk.example.com/YOURNAME/default/microsling

Along with a set of URLs of test documents.

Playing with the dynamic renderers selection

The non-default renderers are separate OpenWhisk actions selected based on annotations prefixed with sling:.

These action annotations are set by the install script but you can change them later as in these examples:

# Vintage! switch to the `htm` extension for the `microsling/somedoc` resource type.
# html will be handled by the default renderer
wsk action update somedoc-html -a sling:extensions htm \
  -a sling:resourceType microsling/somedoc \
  -a sling:contentType text/html

# More vintage! Use the `somedoc-html` renderer for all resource types, with the `htm` extension:
wsk action update somedoc-html -a sling:extensions htm \
  -a sling:resourceType '*' \
  -a sling:contentType text/html

# Back to normal for this `somedoc-html` rendering action
wsk action update somedoc-html rendering-actions/somedoc-html.js \
  -a sling:resourceType microsling/somedoc \
  -a sling:contentType text/html -a sling:extensions html

To create new renderers see the examples in the rendering-actions folder and how they are setup by the install script.

Troubleshooting

To see what happened after executing the action you can use:

wsk -i activation get --last

Or wsk activation list to see what was executed and wsk activation get <ID> to get the data of a specific action activation.

The wsk activation logs command outputs just the logs.

See the Apache OpenWhisk documentation for more information.