-
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 timer actions #19949
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.
Apologies for our delay in getting to this review. Now that we've moved the branch to v2, can you please take a look at resolving the conflicts and/or opening a new PR for this if resolving them is too messy?
d53da27
to
1af03c9
Compare
Pull request has been modified.
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 your work on this! Overall this looks quite good. Please see my specific feedback inline.
* | ||
* @default - none, required if no `durationExpression` is defined. | ||
*/ | ||
readonly duration?: cdk.Duration; |
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.
I'm not a fan of mutually exclusive props. I think this should go in the direction of one required prop that gets translated properly into Duration
or Expression
. Take a look at the model of this we use for Schedule in aws-events
.
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.
Cool! 🤩 I will implement as it. Thank you!
} | ||
} | ||
|
||
bind(_scope: Construct, _options: iotevents.ActionBindOptions): iotevents.ActionConfig { |
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.
bind(_scope: Construct, _options: iotevents.ActionBindOptions): iotevents.ActionConfig { | |
public _bind(_scope: Construct, _options: iotevents.ActionBindOptions): iotevents.ActionConfig { |
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.
This would be better off as it is I think.
This is implementation of IAction
and is following Integration
in DESIGN_GUIDELINE as same as aws-events target.
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.
Yeah, I'm annoyed with that but it's not in scope here to ask you to fix an old contract I'm mad at. Maybe I'll get neurotic about it and do some excessive refactoring.
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.
I've understood that refactoring is necessary even in light of the current implementations.
I'll refactor it!
Pull request has been modified.
- Set variable to detector instanse | ||
- Invoke a Lambda function | ||
|
||
## Use timer |
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.
Excellent README!
iotevents.Expression.inputAttribute(input, 'payload.temperature'), | ||
), | ||
], | ||
new actions.SetVariableAction( |
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.
Good catch
} | ||
} | ||
|
||
bind(_scope: Construct, _options: iotevents.ActionBindOptions): iotevents.ActionConfig { |
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.
Yeah, I'm annoyed with that but it's not in scope here to ask you to fix an old contract I'm mad at. Maybe I'll get neurotic about it and do some excessive refactoring.
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!
Thank you for contributing! Your pull request will be updated from main 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 main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
This PR is a part of roadmap in aws#17711. And if this PR is merged, I will close this issue and create some good first issues to implement rest actions and expressions. This PR supports the timer actions (`SetTimerAction`, `ResetTimerAction` and `ClearTimerAction`) and `timeout()` expression. These allow to embed a timer to the state machine of the detector model. Below figure illustrate the state machine [Device Heartbeat](https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-examples-dhb.html). This detector model is used to alert if the message is interrupted for a certain period of time. The integ-test included in this PR is example of creating Device Heartbeat detector model. ```mermaid stateDiagram-v2 [*] --> Online: set a timer on input message Online --> Online: reset the timer\non input messages Online --> Offline: timeout the timer Offline --> Online: input messages ``` ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/master/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This PR is a part of roadmap in #17711. And if this PR is merged, I will close this issue and create some good first issues to implement rest actions and expressions.
This PR supports the timer actions (
SetTimerAction
,ResetTimerAction
andClearTimerAction
) andtimeout()
expression.These allow to embed a timer to the state machine of the detector model.
Below figure illustrate the state machine Device Heartbeat. This detector model is used to alert if the message is interrupted for a certain period of time. The integ-test included in this PR is example of creating Device Heartbeat detector model.
All Submissions:
Adding new Unconventional Dependencies:
New Features
yarn integ
to deploy the infrastructure and generate the snapshot (i.e.yarn integ
without--dry-run
)?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license