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: session expiry interval to mqtt5 bindings #157

Merged

Conversation

sudoshreyansh
Copy link
Contributor

Description

Adds sessionExpiryInterval to MQTT5 server bindings, which is required for asyncapi/glee#323

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.

Copy link
Member

@fmvilas fmvilas left a comment

Choose a reason for hiding this comment

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

LGTM but you'll have to update the binding version and upgrade it to 0.2.0.

@sudoshreyansh
Copy link
Contributor Author

@fmvilas updated the binding version. Can you please re-review?

@sudoshreyansh sudoshreyansh requested review from fmvilas and removed request for smoya and dalelane October 11, 2022 16:47
fmvilas
fmvilas previously approved these changes Oct 14, 2022
Copy link
Member

@fmvilas fmvilas left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Let's wait for others to review too.

Pinging @KhudaDad414 @derberg @dalelane @smoya @char0n

}
},
"properties": {

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

Copy link
Collaborator

@dalelane dalelane left a comment

Choose a reason for hiding this comment

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

@rcoppen is better placed to comment on this than me, as my MQTT knowledge is pretty rusty... but I'll ask some ignorant questions anyway :-)

Is session expiry an attribute of the server? I thought it was something the client could choose, with different clients connecting to the same server allowed to choose their own (and different) expiries?

@rcoppen
Copy link
Collaborator

rcoppen commented Oct 14, 2022

I agree with @dalelane, is the intention to define a server configuration that always enforces a single Session Expiry for every client connection?

@dan-r
Copy link
Member

dan-r commented Oct 14, 2022

As @dalelane pointed out, the session expiry is sent by the client in the CONNECT packet, although I believe it can technically be overridden by the broker in the CONNACK.

@fmvilas is there a current distinction in the bindings between client-side connection properties and server-side configuration? IMO it would be more logical to define this as something set by a client rather than an 'enforced' value.

@smoya
Copy link
Member

smoya commented Oct 17, 2022

I agree @dalelane and @rcoppen. Session expiration is only a client decision. I tried to think on some way of adding this to the binding, like setting some "max" session TTL, but still it doesn't fit IMHO.
Regarding Glee, you could still use extensions.

@rcoppen
Copy link
Collaborator

rcoppen commented Oct 18, 2022

Looking at the mqtt binding a similar problem exists for clientId. If a value is presented in the AsyncAPI doc then should every client connect with that clientId? This would limit the server to one active client per doc instance. One approach would be to assert a server default in the binding spec should the client not present value. For clientId (assuming MQTT 3.1.1 or 5.0) then that could be a default of "not present" and the server would then create one.

@smoya
Copy link
Member

smoya commented Oct 19, 2022

Looking at the mqtt binding a similar problem exists for clientId. If a value is presented in the AsyncAPI doc then should every client connect with that clientId? This would limit the server to one active client per doc instance.

Good catch!

One approach would be to assert a server default in the binding spec should the client not present value. For clientId (assuming MQTT 3.1.1 or 5.0) then that could be a default of "not present" and the server would then create one.

I wouldn't either set a default, since then the same issue you described earlier could happen.
I would suggest that the type becomes a Schema instead, so users can configure the schema the value should fulfill, including things like default value, regex, etc etc.

But that's for another Issue/PR. Are you happy opening a new issue with this @rcoppen ? I can do otherwise.

@rcoppen
Copy link
Collaborator

rcoppen commented Oct 19, 2022

@smoya np, will open an issue for clientId. My initial thinking was that since MQTT 3.1.1 states that the server will autogenerate a clientId if the client doesn't provide one, then that could be one way to overcome the problem. However I agree that's a discussion for the new issue.

@fmvilas
Copy link
Member

fmvilas commented Oct 20, 2022

Yeah, these things need to be clarified. Y'all are making a good point that this is something the client should decide, maybe even on runtime. I think it could be a good idea to follow the direction of Kafka and WS bindings, and allow either a scalar value or a Schema Object value. The Schema Object should give the client enough flexibility to calculate things on runtime but still make sure it follows a specific pattern or limits. The scalar value would be great for those cases in which we want to enforce a specific value. For instance, when generating code.

@sudoshreyansh
Copy link
Contributor Author

I agree with @fmvilas. I have made the required changes.

mqtt5/README.md Outdated Show resolved Hide resolved
mqtt5/README.md Show resolved Hide resolved
"$ref": "https://raw.githubusercontent.com/asyncapi/spec-json-schemas/v2.14.0/schemas/2.4.0.json#/definitions/schema"
}
],
"description": "Session Expiry Interval in seconds."
Copy link
Member

Choose a reason for hiding this comment

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

Same as above. Something to tweak for the Schema Object case.

@fmvilas
Copy link
Member

fmvilas commented Dec 9, 2022

@derberg @dalelane @char0n please review 🙏

dalelane
dalelane previously approved these changes Dec 10, 2022
@fmvilas
Copy link
Member

fmvilas commented Dec 12, 2022

@KhudaDad414 can you have a look as well, please? 🙏

KhudaDad414
KhudaDad414 previously approved these changes Dec 12, 2022
Copy link
Member

@KhudaDad414 KhudaDad414 left a comment

Choose a reason for hiding this comment

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

LGTM!

@fmvilas
Copy link
Member

fmvilas commented Dec 12, 2022

🏓 @derberg

Copy link
Collaborator

@char0n char0n left a comment

Choose a reason for hiding this comment

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

LGTM. I've suggested couple of changes, due to #143

mqtt5/README.md Outdated

Field Name | Type | Description
---|:---:|---
<a name="serverBindingObjectSessionExpiryInterval"></a>`sessionExpiryInterval` | [Schema Object][schemaObject] \| integer | Session Expiry Interval in seconds or a Schema Object containing the definition of the interval.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<a name="serverBindingObjectSessionExpiryInterval"></a>`sessionExpiryInterval` | [Schema Object][schemaObject] \| integer | Session Expiry Interval in seconds or a Schema Object containing the definition of the interval.
<a name="serverBindingObjectSessionExpiryInterval"></a>`sessionExpiryInterval` | [Schema Object][schemaObject] \| [Reference Object](referenceObject) \| integer | Session Expiry Interval in seconds or a Schema Object containing the definition of the interval.

mqtt5/README.md Outdated
This object MUST NOT contain any properties. Its name is reserved for future use.

[schemaObject]: https://www.asyncapi.com/docs/specifications/2.4.0/#schemaObject
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
[schemaObject]: https://www.asyncapi.com/docs/specifications/2.4.0/#schemaObject
[schemaObject]: https://github.com/asyncapi/spec/blob/master/spec/asyncapi.md#schemaObject
[referenceObject]: https://github.com/asyncapi/spec/blob/master/spec/asyncapi.md#referenceObject

"minimum": 0
},
{
"$ref": "https://raw.githubusercontent.com/asyncapi/spec-json-schemas/v2.14.0/schemas/2.4.0.json#/definitions/schema"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we replace the $ref with following two objects?

   {
    "$ref": "https://asyncapi.com/definitions/2.4.0/schema.json"
   },
   {
     "$ref": "https://asyncapi.com/definitions/2.4.0/Reference.json"
   }

@sudoshreyansh
Copy link
Contributor Author

I have made the changes @char0n
Could you please review?

@fmvilas
Copy link
Member

fmvilas commented Jan 10, 2023

@KhudaDad414 would you mind reapproving if you agree with the changes?

Copy link
Member

@KhudaDad414 KhudaDad414 left a comment

Choose a reason for hiding this comment

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

LGTM!

@fmvilas
Copy link
Member

fmvilas commented Jan 12, 2023

/rtm

@asyncapi-bot asyncapi-bot merged commit de3fe35 into asyncapi:master Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants