-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(iotevents): support transition events #18768
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution @yamatatsu! This is a very interesting functionality that has some interesting challenges, including some nice programming interview question-level sub-tasks 🙂. I'd like to see a few more iterations on the API itself before we can merge this in.
Co-authored-by: Adam Ruka <[email protected]>
Pull request has been modified.
33e3c0f
to
f31211e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fantastic @yamatatsu! So much cleaner and easier to read than the initial version 🙂.
I have a few small last comments, but nothing major.
/** | ||
* The Boolean expression that, when TRUE, causes the state transition and the actions to be performed. | ||
*/ | ||
readonly condition: Expression; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about calling this property when
? This way, the code will read:
someState.transitionTo(otherState, {
when: iotevents.Expression....,
});
Which I think looks really nice 🙂.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yamatatsu I see you did not address this comment. Any reason? Do you disagree with this name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry! I mistakenly lost this task.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skinny85
I've modified it!
Co-authored-by: Adam Ruka <[email protected]>
Pull request has been modified.
Co-authored-by: Adam Ruka <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @yamatatsu! Last round of minor comments.
onEnter: [{ | ||
eventName: 'test-event', | ||
condition: iotevents.Expression.currentInput(input), | ||
when: iotevents.Expression.currentInput(input), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, is this not a weird condition? What does just currentInput()
mean here? Is this true whenever the current input is not empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this true whenever the current input is not empty?
Yes🙂. In this case, Every messages to this input cause this event and create new detector by the property key
.
* | ||
* @default - none (the actions are always executed) | ||
*/ | ||
readonly condition?: Expression; | ||
readonly when?: Expression; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, not sure about this change. My comment was only changing this in TransitionOptions
, not here (it doesn't read that well here as it does in transitionTo()
.
I would leave this as-is. If you feel passionate that this is the way to go, fine, but then we need a "Breaking change" note in the PR description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. I assumed by mistake😅.
* The condition that is used to determine to cause the state transition and the actions. | ||
* When this was evaluated to TRUE, the state transition and the actions are triggered. | ||
*/ | ||
readonly when: Expression; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine to leave this name as condition
(this is a package-private interface, it doesn't really matter what this name is - we can change it at any time. For that same reason, I'm pretty sure you can remove all of the documentation from this interface if you don't need it).
Pull request has been modified.
61ac068
to
da02f80
Compare
/** | ||
* When setting to SERIAL, variables are updated and event conditions are evaluated in the order | ||
* that the events are defined. | ||
* When setting to BATCH, variables within a state are updated and events within a state are | ||
* performed only after all event conditions are evaluated. | ||
*/ | ||
BATCH = 'BATCH', | ||
|
||
/** | ||
* When setting to BATCH, variables within a state are updated and events within a state are | ||
* performed only after all event conditions are evaluated. | ||
* When setting to SERIAL, variables are updated and event conditions are evaluated in the order | ||
* that the events are defined. | ||
*/ | ||
SERIAL = 'SERIAL', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry that my funny mistake😓. Let me include it in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @yamatatsu!
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
This PR allow IoT Events detector model to transit to multiple states. This PR is in roadmap of aws#17711. <img width="561" alt="スクリーンショット 2022-02-02 0 38 10" src="https://user-images.githubusercontent.com/11013683/151999891-45afa8e8-57ed-4264-a323-16b84ed35348.png"> Following image is the graph displayed on AWS console when this integ test deployed. [Compared to the previous version](aws#18049), you can see that the state transitions are now represented. ![image](https://user-images.githubusercontent.com/11013683/151999116-5b3b36b0-d2b9-4e3a-9483-824dc0618f4b.png) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This PR allow IoT Events detector model to transit to multiple states.
This PR is in roadmap of #17711.
Following image is the graph displayed on AWS console when this integ test deployed. Compared to the previous version, you can see that the state transitions are now represented.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license