-
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): allow setting description, evaluation method and key of DetectorModel #18644
Conversation
…`key` of DetectorModel
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 @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'], |
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.
Why this change - seems unrelated to the rest of 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.
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 { |
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 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.
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.
EventEvaluation
is good I think!
* | ||
* @default - none (single detector instance will be created and all inputs will be routed to it) | ||
*/ | ||
readonly key?: string; |
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 name, however, is way, way too generic. How about calling it detectorKey
, or something like that?
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.
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', | ||
}); | ||
}); |
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.
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'], |
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.
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', |
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.
Can't we use payload.temperature
here?
Pull request has been modified.
description
, evaluationMethod
and key
of DetectorModelThere 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 - short and sweet, just the way I like it 😉.
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 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