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: added mqttClientId parameter with a defualt value #295

Conversation

VaishnaviNandakumar
Copy link
Contributor

Description

  • A new parameter mqttClientId with a default value guest was added to package.json.
  • The order in which the value is prioritized is - parameterValue > asyncApiValue > defaultValue

Related issue(s)
Resolves #293

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@VaishnaviNandakumar
Copy link
Contributor Author

@Tenischev Please have a look.

README.md Outdated
|disconnectionTimeout|Only for MQTT. The completion timeout in milliseconds when disconnecting. The default disconnect completion timeout is 5000 milliseconds.|No| `5000` |
|completionTimeout|Only for MQTT. The completion timeout in milliseconds for operations. The default completion timeout is 30000 milliseconds.|No| `30000` |
|asyncapiFileDir| Path where original AsyncAPI file will be stored.|No| `src/main/resources/api/` |
|mqttClientId| Only for MQTT. Provides the client identifier for the MQTT server.|No| guest |
Copy link
Member

Choose a reason for hiding this comment

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

  1. I suggest to move it one row higher. so, all "only mqtt" parameters will be together.
  2. Are you sure that you need to change formatting of all rows?
  3. I suggest to point priority of choosing parameter more clearly e.g. "Overrides the value of the client identifier for the MQTT server, if it is set in the AsyncAPI, otherwise it provides a default value"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @Tenischev

  1. Updated the text and position in README.md and package.json.
  2. No it doesn't require formatting of all rows. In if-elif-else approach, the first check is to see if params.mqttClientId exists. When a default value is set for mqttClientID in package.json , this condition would always be true which is why I removed it and directly put the default value assignment in application.yml.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Tenischev Hi, please take a look at the updated changes.

package.json Outdated
@@ -129,6 +129,11 @@
"description": "Only for Kafka. Add type information to the message header",
"default": "true",
"required": false
},
"mqttClientId": {
"description": "Only for MQTT. Provides the client identifier for the MQTT server.",
Copy link
Member

Choose a reason for hiding this comment

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

same point about description here

{% if server.binding('mqtt') and server.binding('mqtt').clientId %}clientId: {{server.binding('mqtt').clientId}}{% endif %}
{% if server.binding('mqtt') and server.binding('mqtt').cleanSession | isDefined %}cleanSession: {{server.binding('mqtt').cleanSession}}{% endif %}
{% if server.binding('mqtt') and server.binding('mqtt').lastWill %}lastWill:
{% if server.binding('mqtt') and server.binding('mqtt').clientId and (params.mqttClientId == 'guest') %}
Copy link
Member

Choose a reason for hiding this comment

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

I see the problem if in AsyncAPI server.binding('mqtt').clientId = provider (example), but user would like to intentionally change it to guest via parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. I had an approach where I made use of an if-elif condition like this -

{% if params.mqttClientId %}
clientId : {{ params.mqttClientId }}
{% elif if server.binding('mqtt') and server.binding('mqtt').clientId %}
clientId: {{ server.binding('mqtt').clientId }}
{% else %}
clientId: defaultValue
{% endif %}

But this requires the default value to be removed from package.json and I wasn't sure if it was better. What do you think?

@Tenischev Tenischev changed the title Added mqttClientId parameter with a defualt value feat: added mqttClientId parameter with a defualt value May 22, 2023
Copy link
Member

@Tenischev Tenischev left a comment

Choose a reason for hiding this comment

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

LGTM

@Tenischev Tenischev merged commit f319c00 into asyncapi:master May 24, 2023
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 0.29.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing clientId in application.yml causing an error
3 participants