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(data): Make Core Data publish events to <TopicPrefix>/<DeviceProfile>/<DeviceName> #3002

Merged
merged 4 commits into from
Jan 14, 2021

Conversation

judehung
Copy link
Member

@judehung judehung commented Jan 8, 2021

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/edgex-go/blob/master/.github/Contributing.md.

What is the current behavior?

Issue Number:

fix #2934
fix #2995

What is the new behavior?

Per https://github.com/edgexfoundry/edgex-docs/blob/master/docs_src/design/adr/013-Device-Service-Events-Message-Bus.md, Core data shall publish Events to //.

This PR made following changes:

  1. Add new property PublishTopicPrefix into MessageQueue configuration.

  2. Update Core Data configuration.toml to add PublishTopicPrefix set it to:
    PublishTopicPrefix = 'edgex/events' # // will be added to this Publish Topic prefix

  3. Change V2 Add Event endpoint to be /event/{DeviceProfileName}/{DeviceName}

  4. When publishing V2 Event DTO use topic PublishTopicPrefix+ /{DeviceProfileName}/{DeviceName}

  5. Publish []AddEventRequestDTO instead of single EventDTO to message queue

Does this PR introduce a breaking change?

  • Yes
  • No

New Imports

  • Yes
  • No

@judehung judehung changed the title feat(data): Core Data publish to <TopicPrefix>/<DeviceProfile>/<DeviceName> feat(data): Make Core Data publish events to <TopicPrefix>/<DeviceProfile>/<DeviceName> Jan 8, 2021
@judehung judehung marked this pull request as ready for review January 8, 2021 11:43
internal/core/data/config/config.go Show resolved Hide resolved
internal/core/data/v2/application/event.go Outdated Show resolved Hide resolved
internal/core/data/v2/application/event.go Outdated Show resolved Hide resolved
internal/core/data/v2/application/event.go Show resolved Hide resolved
internal/core/data/v2/application/event.go Outdated Show resolved Hide resolved
internal/core/data/v2/controller/http/event.go Outdated Show resolved Hide resolved
internal/core/data/v2/controller/http/event.go Outdated Show resolved Hide resolved
internal/core/data/v2/controller/http/event.go Outdated Show resolved Hide resolved
internal/core/data/v2/controller/http/event.go Outdated Show resolved Hide resolved
internal/core/data/v2/controller/http/event_test.go Outdated Show resolved Hide resolved
@judehung
Copy link
Member Author

@lenny-intel All of your comments have been addressed by the second commit 66ea3a1 Please kindly take a look. Thanks!

Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

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

Code looks good, we now just need to resolve the issue of multiple AddEventRequest vs single AddEventRequest published to the MessageBus (JSON & CBOR).

@judehung
Copy link
Member Author

rebased and squashed 2 commits into 1 commit.

judehung added a commit to judehung/go-mod-core-contracts that referenced this pull request Jan 13, 2021
Per discussion over edgexfoundry/edgex-go#3002 (comment), AddEvent V2 API shall be updated to deal with single AddEventRequest DTO instead of AddEventRequest DTO array. As a result, func AddEventReqToEventModels shall be updated accordingly.

fix edgexfoundry#429

Signed-off-by: Jude Hung <jude@iotechsys.com>
judehung added a commit to judehung/go-mod-core-contracts that referenced this pull request Jan 13, 2021
Per discussion over edgexfoundry/edgex-go#3002 (comment), AddEvent V2 API shall be updated to deal with single AddEventRequest DTO instead of AddEventRequest DTO array. As a result, func AddEventReqToEventModels shall be updated accordingly.

fix edgexfoundry#429

Signed-off-by: Jude Hung <jude@iotechsys.com>
judehung added a commit to judehung/go-mod-core-contracts that referenced this pull request Jan 13, 2021
Per discussion over edgexfoundry/edgex-go#3002 (comment), AddEvent V2 API shall be updated to deal with single AddEventRequest DTO instead of AddEventRequest DTO array. As a result, func AddEventReqToEventModels shall be updated accordingly.

fix edgexfoundry#429

Signed-off-by: Jude Hung <jude@iotechsys.com>
judehung added a commit to judehung/go-mod-core-contracts that referenced this pull request Jan 13, 2021
Per discussion over edgexfoundry/edgex-go#3002 (comment), AddEvent V2 API shall be updated to deal with single AddEventRequest DTO instead of AddEventRequest DTO array. As a result, func AddEventReqToEventModels shall be updated accordingly.

fix edgexfoundry#429

Signed-off-by: Jude Hung <jude@iotechsys.com>
judehung added a commit to judehung/edgex-go that referenced this pull request Jan 13, 2021
Per discussion over edgexfoundry#3002 (comment), AddEvent V2 API shall be updated to deal with single AddEventRequest DTO instead of AddEventRequest DTO array. This commit makes such changes.

Signed-off-by: Jude Hung <jude@iotechsys.com>
judehung added a commit to judehung/edgex-go that referenced this pull request Jan 13, 2021
Per discussion over edgexfoundry#3002 (comment), AddEvent V2 API shall be updated to deal with single AddEventRequest DTO instead of AddEventRequest DTO array. This commit makes such changes and also updates the swagger API doc.

Signed-off-by: Jude Hung <jude@iotechsys.com>
judehung added a commit to judehung/edgex-go that referenced this pull request Jan 13, 2021
Per discussion over edgexfoundry#3002 (comment), AddEvent V2 API shall be updated to deal with single AddEventRequest DTO instead of AddEventRequest DTO array. This commit makes such changes and also updates the swagger API doc.

Signed-off-by: Jude Hung <jude@iotechsys.com>
judehung added a commit to judehung/edgex-go that referenced this pull request Jan 13, 2021
Per discussion over edgexfoundry#3002 (comment), AddEvent V2 API shall be updated to deal with single AddEventRequest DTO instead of AddEventRequest DTO array. This commit makes such changes and also updates the swagger API doc.

Signed-off-by: Jude Hung <jude@iotechsys.com>
internal/core/data/v2/application/event.go Outdated Show resolved Hide resolved
internal/core/data/v2/application/event.go Outdated Show resolved Hide resolved
openapi/v2/core-data.yaml Outdated Show resolved Hide resolved
…eName>

Per https://github.com/edgexfoundry/edgex-docs/blob/master/docs_src/design/adr/013-Device-Service-Events-Message-Bus.md, Core data shall publish Events to <TopicPrefix>/<DeviceProfile>/<DeviceName>.

This commit made following changes:

1. Add new property PublishTopicPrefix into MessageQueue configuration.

2. Update Core Data configuration.toml to add PublishTopicPrefix set it to:
PublishTopicPrefix = 'edgex/events' # /<device-profile-name>/<device-name> will be added to this Publish Topic prefix

3. Change V2 Add Event endpoint to be /event/{DeviceProfileName}/{DeviceName}

4. When publishing V2 Event DTO use topic PublishTopicPrefix+ /{DeviceProfileName}/{DeviceName}

Update the codes per review comments:
1. Add TODO to remove Topic when V1 code is removed.
2. Remove empty string validation as it will catch by event
deive/profile name match check
3. Change validateEvent to ValidateEvent and move the validation to
protocal layer(event controller)
4. Remove event id return from apllication layer
5. Update swagger doc for API path changes and profile/device name
consistency check
6. Add reader back to event controller, and have AddEvent reuse the
reader from event controller.

Signed-off-by: Jude Hung <jude@iotechsys.com>
Per discussion over edgexfoundry#3002 (comment), AddEvent V2 API shall be updated to deal with single AddEventRequest DTO instead of AddEventRequest DTO array. This commit makes such changes and also updates the swagger API doc.

Signed-off-by: Jude Hung <jude@iotechsys.com>
1. Update go doc for func PublishEvent
2. Update debug log when publishing event on the message queue
3. Update description for core-data V2 swagger API doc

Signed-off-by: Jude Hung <jude@iotechsys.com>
@judehung
Copy link
Member Author

rebased and updated code per review comments from Lenny.
@lenny-intel please kindly take a look for PR changes on bce2c04

@codecov-io
Copy link

codecov-io commented Jan 14, 2021

Codecov Report

Merging #3002 (3f947bb) into master (9e7cc68) will decrease coverage by 0.07%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3002      +/-   ##
==========================================
- Coverage   40.34%   40.27%   -0.08%     
==========================================
  Files         159      159              
  Lines       13961    13962       +1     
==========================================
- Hits         5633     5623      -10     
- Misses       7997     8011      +14     
+ Partials      331      328       -3     
Impacted Files Coverage Δ
internal/core/data/v2/application/event.go 56.75% <50.00%> (-11.14%) ⬇️
internal/core/data/v2/controller/http/event.go 79.03% <76.92%> (+0.77%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9e7cc68...3f947bb. Read the comment docs.

@sonarcloud
Copy link

sonarcloud bot commented Jan 14, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
6.7% 6.7% Duplication

Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

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

LGTM

@lenny-goodell lenny-goodell merged commit cd24e07 into edgexfoundry:master Jan 14, 2021
@judehung judehung deleted the issue-2934 branch January 15, 2021 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants