apache / apache/openwhisk

Best practices and confusion...

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

Description

Hi everyone.. i'm trying to understand the right way to to thing with actions, trigger, rules and serverless in general.
My idea is:
When a triggers fires, a sequence of actions must start -> generate a random color, turn on a led with that color, save to a DB the record using an input ID, timestamp and the color generated at the first step.

I need to fire the trigger using the OW API.

so i did like so:
![IMG_0493 3](https://user-images.githubusercontent.com/6717214/141679615-868b2365-493e-4d79-8c43-5b0a26eb41ef.jpg)

the problem is that the parameters you pass to the trigger at the beginning is used ONLY from the first action (_generateColor_), then them are lost, same thing apply for the output of the actions.. the output of _generateColor_ is needed for _turnOnLED_ and _saveColor_, but the last will not receive the data because there is another action in between, and also will not receive the parameters used to fire the trigger (needed to save the record to the DB)
![IMG_0493](https://user-images.githubusercontent.com/6717214/141679779-e6ccebb5-7a06-473f-818c-b9e3115e198d.jpg)

Last but not least... keeping in mind that the trigger will be fired using the API, you should expect sometype of response.. instead you got only an activationid relative to the trigger. This means:
Imagine the above sequence works. saveColor returns a value (in this case called "record-id"), when you fire to trigger you expect this as output, but instead you have to:

1. Get the activationId of the trigger
2. Make another api request to get the activations of the single actions used by the sequence
3. Make another api request to get the result result of the action you need in the list found before, so you have to try one by one (in this case are only 3, but if were 50?)

At this point i think i'm doing something wrong, this is not the right way to design actions? how should they be done? my understanding of "serverless" is wrong?.. i don't know but this thing is a bit confusing to me.

Thanks in advance

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.