Skip to content
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): allow setting description, evaluation method and key of DetectorModel #18644

Merged
merged 4 commits into from
Jan 27, 2022

Conversation

yamatatsu
Copy link
Contributor

This PR is about #17711 (but out of the roadmap).
This PR (especially key property) make it easier to test the features we will implement.


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

gitpod-io bot commented Jan 25, 2022

@github-actions github-actions bot added the @aws-cdk/aws-iotevents Related to AWS IoT Events label Jan 25, 2022
Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

Thanks @yamatatsu! Minor notes, mainly about naming.

@@ -51,7 +51,7 @@ import * as iotevents from '@aws-cdk/aws-iotevents';

const input = new iotevents.Input(this, 'MyInput', {
inputName: 'my_input', // optional
attributeJsonPaths: ['payload.temperature'],
attributeJsonPaths: ['payload.deviceId', 'payload.temperature'],
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change - seems unrelated to the rest of this PR...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I modified this for the sake of reality.
The path passed in detectorKey must be declared in this attributeJsonPaths. And the value passed in detectorKey is often the unique value of the device or device group.
This is because IoT Events is often used to monitor devices and device groups.

I modified integ test for the same reason.

/**
* Information about the order in which events are evaluated and how actions are executed.
*/
export enum EvaluationMethod {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this name too generic? Should this be EventEvaluationMethod, or StateEvaluationMethod, or DetectorActionEvaluationMethod, or something?

Actually, can we even kill the "Method" suffix here? I don't think it adds much, and just makes the name longer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

EventEvaluation is good I think!

packages/@aws-cdk/aws-iotevents/lib/detector-model.ts Outdated Show resolved Hide resolved
*
* @default - none (single detector instance will be created and all inputs will be routed to it)
*/
readonly key?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

This name, however, is way, way too generic. How about calling it detectorKey, or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

detectorKey is good! Hmm... I should think for more understandability instead of CFn copy. Thank you!

Template.fromStack(stack).hasResourceProperties('AWS::IoTEvents::DetectorModel', {
Key: 'payload.deviceId',
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's just do all 3 in one test. Spreading them out like that just makes the tests longer, it doesn't really improve coverage in any way.

@@ -7,7 +7,7 @@ class TestStack extends cdk.Stack {

const input = new iotevents.Input(this, 'MyInput', {
inputName: 'test_input',
attributeJsonPaths: ['payload.temperature'],
attributeJsonPaths: ['payload.deviceId', 'payload.temperature'],
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, why are we changing existing things?

@@ -27,6 +27,9 @@ class TestStack extends cdk.Stack {

new iotevents.DetectorModel(this, 'MyDetectorModel', {
detectorModelName: 'test-detector-model',
detectorModelDescription: 'test-detector-model-description',
evaluationMethod: iotevents.EvaluationMethod.SERIAL,
key: 'payload.deviceId',
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we use payload.temperature here?

@mergify mergify bot dismissed skinny85’s stale review January 27, 2022 12:15

Pull request has been modified.

@skinny85 skinny85 changed the title feat(iotevents): allow setting description, evaluationMethod and key of DetectorModel feat(iotevents): allow setting description, evaluation method and key of DetectorModel Jan 27, 2022
Copy link
Contributor

@skinny85 skinny85 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 @yamatatsu - short and sweet, just the way I like it 😉.

@mergify
Copy link
Contributor

mergify bot commented Jan 27, 2022

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

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: dba6fd4
  • 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 2eeaebc into aws:master Jan 27, 2022
@mergify
Copy link
Contributor

mergify bot commented Jan 27, 2022

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

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
… of DetectorModel (aws#18644)

This PR is about aws#17711 (but out of the roadmap).
This PR (especially `key` property) make it easier to test the features we will implement.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@yamatatsu yamatatsu deleted the iotevents-dm-other-properties branch April 6, 2022 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-iotevents Related to AWS IoT Events
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants