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

Refactoring MQTT state management #88

Merged
merged 7 commits into from
Aug 22, 2022
Merged

Conversation

ryan-summers
Copy link
Member

This PR refactors the state management of the client to be entirely wrapped up in an smlang::StateMachine.

This change is intended to support more complex state management that will be required to support all QoS levels.

This PR also removes public access to the Minimq.client object. It is now exposed via Minimq::client() to support compatibility going forward.

Copy link
Member

@jordens jordens left a comment

Choose a reason for hiding this comment

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

I'd move a bunch of code down into ClientContext, basically everything that doesn't need state() or process_event(). That frees you from having to unpack ClientContext all the time and having to reaching down into it with context_mut() so often. Instead in MqttClient there'll be almost exclusively process_event() and state() and then a call
like context_mut().handle_something().

But otherwise good.

src/mqtt_client.rs Outdated Show resolved Hide resolved
src/mqtt_client.rs Outdated Show resolved Hide resolved
src/mqtt_client.rs Outdated Show resolved Hide resolved
src/mqtt_client.rs Outdated Show resolved Hide resolved
@ryan-summers ryan-summers force-pushed the feature/state-refactor branch from bc84e46 to 3c029d0 Compare August 19, 2022 12:15
@ryan-summers
Copy link
Member Author

@jordens I elected to restructure it so that we only keep the SessionState as the state machine context. This should still facilitate easy management of the session state structure. There's still a small amount of reaching into the internal context, but I want to try to fix it up a bit later.

@ryan-summers ryan-summers requested a review from jordens August 19, 2022 13:47
Copy link
Member

@jordens jordens left a comment

Choose a reason for hiding this comment

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

Just a minor thing. LGTM otherwise

src/mqtt_client.rs Outdated Show resolved Hide resolved
@ryan-summers ryan-summers requested a review from jordens August 22, 2022 14:48
@ryan-summers ryan-summers merged commit fa34ffb into master Aug 22, 2022
@ryan-summers ryan-summers deleted the feature/state-refactor branch August 22, 2022 14:53
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.

2 participants