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!: replace REST device callbacks with System Events #1276

Merged
merged 1 commit into from
Jan 18, 2023

Conversation

chr1shung
Copy link

BREAKING CHANGE:
the following device callback REST endpoints are removed:

  • POST /callback/device
  • PUT /callback/device
  • DELETE /callback/device/name/{name}

closes #1259

Signed-off-by: Chris Hung chris@iotechsys.com

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

PR Checklist

Please check if your PR fulfills the following requirements:

  • I am not introducing a breaking change (if you are, flag in conventional commit message with BREAKING CHANGE: describing the break)
  • I am not introducing a new dependency (add notes below if you are)
  • I have added unit tests for the new feature or bug fix (if not, why?)
  • I have fully tested (add details below) this the new feature or bug fix (if not, why?)
  • I have opened a PR for the related docs change (if not, why?)

Testing Instructions

  1. Run device-simple from this branch with WRITABLE_LOGLEVEL: DEBUG
  2. Verified the device callback is correctly invoked:
level=DEBUG ts=2023-01-10T06:07:13.750646Z app=device-simple source=callback.go:55 msg="System event received on message queue. Topic: edgex/system-events/#, Correlation-id: f7a5e7ea-d1cb-4a67-bc31-16ae0b60f0c4 "
level=DEBUG ts=2023-01-10T06:07:13.755268Z app=device-simple source=callback.go:56 msg="device Simple-Device01 added"
level=DEBUG ts=2023-01-10T06:07:13.75529Z app=device-simple source=simpledriver.go:292 msg="a new Device is added: Simple-Device01"
level=DEBUG ts=2023-01-10T06:07:13.755302Z app=device-simple source=callback.go:61 msg="Invoked driver.AddDevice callback for Simple-Device01"

New Dependency Instructions (If applicable)

@codecov-commenter
Copy link

Codecov Report

Merging #1276 (6a7a60c) into main (8025d41) will increase coverage by 0.62%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main    #1276      +/-   ##
==========================================
+ Coverage   50.26%   50.89%   +0.62%     
==========================================
  Files          27       27              
  Lines        2441     2405      -36     
==========================================
- Hits         1227     1224       -3     
+ Misses       1108     1075      -33     
  Partials      106      106              
Impacted Files Coverage Δ
internal/controller/http/callback.go 0.00% <ø> (ø)
internal/controller/http/restrouter.go 76.31% <ø> (-0.90%) ⬇️
pkg/service/main.go 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@TomBrennan-Eaton
Copy link

While System Events are the better way (compared to REST callbacks), and the way I'd want to use, did we decide that they were to be the only way for everybody?

@lenny-goodell
Copy link
Member

While System Events are the better way (compared to REST callbacks), and the way I'd want to use, did we decide that they were to be the only way for everybody?

Yes, no need for both options as this is internal between Core Metadata and the Device Services. All handled in the SDKs.

@@ -85,6 +85,7 @@ PublishTopicPrefix = "edgex/events/device" # /<device-profile-name>/<device-name
[MessageQueue.Topics]
CommandRequestTopic = "edgex/device/command/request/device-simple/#" # subscribing for inbound command requests
CommandResponseTopicPrefix = "edgex/device/command/response" # publishing outbound command responses; <device-service>/<device-name>/<command-name>/<method> will be added to this publish topic prefix
SystemEventTopic = "edgex/system-events/#"
Copy link
Member

Choose a reason for hiding this comment

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

Do we want make this more specific to core-metadata device system events and ones only for this service?

/<source>/<type>/<action>/<owner>/<profile> will be added to this Publish Topic

Suggested change
SystemEventTopic = "edgex/system-events/#"
SystemEventTopic = "edgex/system-events/core-metadata/device/#/device-simple/#"

internal/controller/messaging/callback.go Show resolved Hide resolved
lenny-goodell
lenny-goodell previously approved these changes Jan 11, 2023
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 - @cloudxxx8 Note there needs to be specific PRs for each Device service to consume this since their configuration needs to be updated. i.e. can't just merge depend-a-bot PRs

lenny-goodell
lenny-goodell previously approved these changes Jan 13, 2023
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

Copy link
Member

@cloudxxx8 cloudxxx8 left a comment

Choose a reason for hiding this comment

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

please remove the API from the Swagger file as well

@chr1shung
Copy link
Author

please remove the API from the Swagger file as well

do we need to create a openapi/v3 directory for the change ?

@cloudxxx8
Copy link
Member

please remove the API from the Swagger file as well

do we need to create a openapi/v3 directory for the change ?

yes, you are right. please create a openapi/v3 directory.
please also add the changelog.txt as /v2 did. thanks

BREAKING CHANGE:
the following device callback REST endpoints are removed:
- POST /callback/device
- PUT /callback/device
- DELETE /callback/device/name/{name}

closes edgexfoundry#1259

Signed-off-by: Chris Hung <chris@iotechsys.com>
Copy link
Member

@cloudxxx8 cloudxxx8 left a comment

Choose a reason for hiding this comment

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

LGTM

@cloudxxx8 cloudxxx8 merged commit f7483b2 into edgexfoundry:main Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace Device Add/Update/Delete REST API with Device System Events
5 participants