In an earlier email discussion [1] Tyson noted the previously
discussed idea of using a context object per activation in lieu of
environment variables which are currently exported by the
system/runtime per activation. This was previously discussed in [2]
and is necessary to separate intra-container concurrency where
otherwise environment variables would clobber each other.

I have an implementation of the nodejs proxy which allows one to
specify the main handlers with a context object.
exports.main = (args, context) => { }

I've only done it for nodejs and don't currently have plans to support
other runtimes. I'm happy to open a PR against the nodejs repo for
this. The patch does not export the __OW context objects and instead
uses methods/getters on the context object. In doing this mapping, I
adopted AWS Lambda's model for the method names, so that you can take
an AWS lambda for nodejs and run it in OpenWhisk.

Of course there are some caveats. Two primarily:
- the first is that if a AWS lambda that makes heavy use of AWS
specific features provided to it, they will not have analogs.
- AWS is somehow detecting that the node event loop has emptied and
can block the lambda (or return) depending on the event loop status. I
haven't replicated this behavior in openwhisk.

In any case, the Lambda compatibility for nodejs is tangentially
related to the point I started with: it already provides a context
object which can address Tyson's issue [2].

-r

[1] 
https://lists.apache.org/thread.html/d0791b9397f1fcd2a0e47290381fd94bc9a76744ff4837288be027c1@%3Cdev.openwhisk.apache.org%3E

[2] https://github.com/apache/incubator-openwhisk/issues/4020

-r

Reply via email to