apache / apache/openwhisk

override action entry point on web action invoke

Open
#4,349 4 comments 0 reactions 0 assignees View on GitHub
discussion enhancement
Dominant language
Scala
Stars
6.8k
Forks
1.2k
Avg merge
2d 14h
Merged PRs (30d)
2

Description

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.

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

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

```
wsk action create hello --web true hello.js
```

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 `@` as the new entry point.

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

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.