When one creates an action today, they can specify the main entry point at
creation time. For example:

  wsk action create myfn f.js --main foo

This allows a single file with multiple functions to be used as different
actions.

But this is wasteful - one has to create multiple actions this way and
we're paying the cost in the backend by replicating the code (in the
database, and multiple code fetches).

What if the main was specified on invoke instead? For example, take a web
action from this file hello.js

  function niam(args) { return { 'greetings': 'Hello from a
non-standard entrypoint.' } }  function main(args) { return {
'greetings': 'Hello from a standard entrypoint.' } }

We could allow main to be set on the action activation.

> curl -k https://guest.localhost/default/hello.json
{
  "greetings": "Hello from a standard entrypoint."
}

And now with an override to "main", using @<new main> as the new entry
point.

> curl -k https://guest.localhost/default/hello.json@niam
{
  "greetings": "Hello from a non-standard entrypoint."
}

I created an issue to discuss the idea [1].

I'm thinking primarily to restrict this to web actions initially, although
there are some extensions that are also reasonable to consider subsequently:

   1. we could also make it work for POST invoke, namely wsk action invoke
   --main.
   2. we can extend it to sequences so that you can create a sequence from
   fn@main1, fn@main2
   3. we can further extend it to conductor continuations

[1] https://github.com/apache/incubator-openwhisk/issues/4349

Reply via email to