Skip to content

Conversation

@weichou1229
Copy link
Member

@weichou1229 weichou1229 commented Aug 29, 2025

Allow Event Reading API to pass a numeric parameter.

Updated the EventClient and ReadingClient interfaces to add a new function XXXXWithQueryParams. This was done to maintain backward compatibility, ensuring that other services using these client libraries won’t need to make significant code changes.

If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/go-mod-core-contracts/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?) not impact

Testing Instructions

New Dependency Instructions (If applicable)

@codecov-commenter
Copy link

codecov-commenter commented Aug 29, 2025

Codecov Report

❌ Patch coverage is 88.88889% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.83%. Comparing base (7c1cc7e) to head (9ee158e).

Files with missing lines Patch % Lines
clients/http/utils/common.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1019      +/-   ##
==========================================
- Coverage   44.91%   44.83%   -0.08%     
==========================================
  Files         128      128              
  Lines        7555     7554       -1     
==========================================
- Hits         3393     3387       -6     
- Misses       3803     3808       +5     
  Partials      359      359              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Allow Event Reading API to pass numeric parameter

Signed-off-by: bruce <[email protected]>
@weichou1229 weichou1229 requested a review from judehung September 1, 2025 03:59
@weichou1229 weichou1229 marked this pull request as ready for review September 1, 2025 04:00
Copy link
Member

@judehung judehung left a comment

Choose a reason for hiding this comment

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

@weichou1229 For tracking purposes, please include a description in the PR noting that you updated the EventClient and ReadingClient interfaces with XXXXWithQueryParams. This was done to maintain backward compatibility, ensuring that other services using these client libraries won’t need to make significant code changes.

dtos/reading.go Outdated
switch v := aux.Value.(type) {
case string: // string, for JSON strings
b.Value = v
case float64: // float64, for JSON numbers
Copy link
Member

Choose a reason for hiding this comment

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

Add more explanation in comment to describe why only deal with float64 here

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated according to Cloud's comment. The json lib treats all number type as float64, so we don't need to handle other types.

// limit: The number of items to return. Specify -1 will return all remaining items after offset. The maximum will be the MaxResultCount as defined in the configuration of service. Default is 20.
EventsByDeviceName(ctx context.Context, name string, offset, limit int) (responses.MultiEventsResponse, errors.EdgeX)
// EventsByDeviceNameWithQueryParams returns a portion of the entire events according to the device name and specified query parameters. Events are sorted in descending order of created time.
EventsByDeviceNameWithQueryParams(ctx context.Context, name string, queryParams map[string]string) (responses.MultiEventsResponse, errors.EdgeX)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
EventsByDeviceNameWithQueryParams(ctx context.Context, name string, queryParams map[string]string) (responses.MultiEventsResponse, errors.EdgeX)
EventsByDeviceNameWithQueryParams(ctx context.Context, name string, offset, limit int, queryParams map[string]string) (responses.MultiEventsResponse, errors.EdgeX)

Copy link
Member Author

Choose a reason for hiding this comment

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

The offset and limit are part of the query parameter, so I remove offset, limit int from the function argument.
For example, http://0.0.0.0:59880/api/v3/event/device/name/Random-UnsignedInteger-Device?offset=0&limit=3&numeric=true

Copy link
Member Author

Choose a reason for hiding this comment

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

Added the offset, limit back.

// limit: The number of items to return. Specify -1 will return all remaining items after offset. The maximum will be the MaxResultCount as defined in the configuration of service. Default is 20.
EventsByTimeRange(ctx context.Context, start, end int64, offset, limit int) (responses.MultiEventsResponse, errors.EdgeX)
// EventsByTimeRangeWithQueryParams returns events between a given start, end date/time, and specified query parameters. Events are sorted in descending order of created time.
EventsByTimeRangeWithQueryParams(ctx context.Context, start, end int64, queryParams map[string]string) (responses.MultiEventsResponse, errors.EdgeX)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
EventsByTimeRangeWithQueryParams(ctx context.Context, start, end int64, queryParams map[string]string) (responses.MultiEventsResponse, errors.EdgeX)
EventsByTimeRangeWithQueryParams(ctx context.Context, start, end int64, offset, limit int, queryParams map[string]string) (responses.MultiEventsResponse, errors.EdgeX)

Copy link
Member Author

Choose a reason for hiding this comment

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

The offset and limit are part of the query parameter, so I remove offset, limit int from the function argument.
For example, http://0.0.0.0:59880/api/v3/event/start/1102168089665565200/end/1840986079160530000?offset=2&numeric=true

Copy link
Member Author

Choose a reason for hiding this comment

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

Added the offset, limit back.

if the value is not string, let the NumericReading contain the equivalent value

Signed-off-by: bruce <[email protected]>
judehung
judehung previously approved these changes Sep 2, 2025
Copy link
Member

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

generate mock client

Added offset and limit parameters to the Event and Reading client XXXWithQueryParams functions for easier use.

Signed-off-by: bruce <[email protected]>
@weichou1229
Copy link
Member Author

generate mock client

Generated Event and Reading mock client.

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 bb1a0b1 into edgexfoundry:main Sep 3, 2025
3 checks passed
@weichou1229 weichou1229 deleted the numeric-value branch September 4, 2025 00:57
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.

4 participants