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

fix: create consistent interface 'with_node' for API access #10237

Conversation

sstrigler
Copy link
Contributor

@sstrigler sstrigler commented Mar 24, 2023

Fixes EMQX-9138

PR Checklist

Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked:

  • Added tests for the changes
  • Changed lines covered in coverage report
  • Change log has been added to changes/{ce,ee}/(feat|perf|fix)-<PR-id>.en.md and .zh.md files
  • For internal contributor: there is a jira ticket to track this change
  • [-] If there should be document changes, a PR to emqx-docs.git is sent, or a jira ticket is created to follow up
  • Schema changes are backward compatible

@sstrigler sstrigler marked this pull request as ready for review March 24, 2023 15:55
@sstrigler sstrigler requested review from a team, lafirest and JimMoen as code owners March 24, 2023 15:55
@sstrigler sstrigler force-pushed the EMQX-9138-e-5-0-2-ensure-that-the-error-messages-returned-are-consistent branch 4 times, most recently from 6bfc286 to ccfd3f4 Compare March 27, 2023 08:27
@sstrigler sstrigler force-pushed the EMQX-9138-e-5-0-2-ensure-that-the-error-messages-returned-are-consistent branch from ccfd3f4 to 0017be3 Compare March 27, 2023 09:32
-ifndef(EMQX_API_LIB_HRL).
-define(EMQX_API_LIB_HRL, true).

-define(ERROR_MSG(CODE, REASON), #{code => CODE, message => emqx_misc:readable_error_msg(REASON)}).
Copy link
Contributor

Choose a reason for hiding this comment

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

(Maybe for future discussion): I always wondered why we should have all the responses as macros. We do not match against them anywhere, and the performance impact should be neglectable 🤔

Copy link
Contributor Author

@sstrigler sstrigler Mar 27, 2023

Choose a reason for hiding this comment

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

I think it vastly improves readability and consistency, my goal rather is to ONLY use those macros throughout than constructing all those responses by hand.

Or is it, that you would favor function calls instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(Also I match against them in my tests)

Copy link
Contributor

Choose a reason for hiding this comment

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

that you would favor function calls instead?

Yes, I mean

error_msg(Code, Reason) ->
...

vs

-define(ERROR_MSG(CODE, REASON), ...).

savonarola
savonarola previously approved these changes Mar 27, 2023
@sstrigler sstrigler force-pushed the EMQX-9138-e-5-0-2-ensure-that-the-error-messages-returned-are-consistent branch from 0017be3 to 64a1d84 Compare March 27, 2023 10:14
@sstrigler sstrigler requested a review from ieQu1 March 28, 2023 08:32
@sstrigler sstrigler merged commit 193905c into emqx:master Mar 28, 2023
100 checks passed
@sstrigler sstrigler deleted the EMQX-9138-e-5-0-2-ensure-that-the-error-messages-returned-are-consistent branch March 28, 2023 08:41
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.

None yet

4 participants