Skip to content

feat(iotevents): support timer actions#19949

Merged
mergify[bot] merged 4 commits intoaws:mainfrom
yamatatsu:iotevents-actions-timer
Aug 3, 2022
Merged

feat(iotevents): support timer actions#19949
mergify[bot] merged 4 commits intoaws:mainfrom
yamatatsu:iotevents-actions-timer

Conversation

@yamatatsu
Copy link
Copy Markdown
Contributor

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 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. 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.

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
Loading

All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • 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

@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Apr 18, 2022

@aws-cdk-automation aws-cdk-automation requested a review from a team April 18, 2022 01:38
@github-actions github-actions bot added the p2 label Apr 18, 2022
@TheRealAmazonKendra TheRealAmazonKendra changed the base branch from v1-main to main July 13, 2022 00:06
Copy link
Copy Markdown
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a 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?

@yamatatsu yamatatsu force-pushed the iotevents-actions-timer branch from d53da27 to 1af03c9 Compare July 31, 2022 13:02
@mergify mergify bot dismissed TheRealAmazonKendra’s stale review July 31, 2022 13:03

Pull request has been modified.

Copy link
Copy Markdown
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a 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;
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

@yamatatsu yamatatsu Aug 2, 2022

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 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bind(_scope: Construct, _options: iotevents.ActionBindOptions): iotevents.ActionConfig {
public _bind(_scope: Construct, _options: iotevents.ActionBindOptions): iotevents.ActionConfig {

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor Author

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!

@mergify mergify bot dismissed TheRealAmazonKendra’s stale review August 2, 2022 14:57

Pull request has been modified.

@TheRealAmazonKendra TheRealAmazonKendra changed the title feat(iotevents): Support the timer actions feat(iotevents): support timer actions Aug 3, 2022
- Set variable to detector instanse
- Invoke a Lambda function

## Use timer
Copy link
Copy Markdown
Contributor

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(
Copy link
Copy Markdown
Contributor

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 {
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Aug 3, 2022

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-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 9c62a4a
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit af301dd into aws:main Aug 3, 2022
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Aug 3, 2022

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants