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

Update mqtt proxy to broker #876

Merged
merged 13 commits into from
Dec 22, 2022

Conversation

suchen-sci
Copy link
Contributor

@suchen-sci suchen-sci commented Dec 14, 2022

this pr is to make MQTTProxy support broker mode by set brokerMode true in spec. Original MQTTProxy only publish messages to backend Kafka. Now, MQTTProxy not only publish message to Kafka but also send messages to the subscribed clients directly.

Main changes:

  1. cachedTopicManager: it contains topic and mqtt client mapping information from all easegress nodes.
  2. SessionCacheManager: it contains all session information for all mqtt clients from all easegress nodes and update cachedTopicManager.
  3. broker: watch etcd changes and update SessionCacheManager.
  4. other updates include optim resend and store, solve conflict of client connect to new easegress instance without disconnect previous one (more details in comment).

@suchen-sci
Copy link
Contributor Author

Previous comment is in #874 . Sorry for inconvince...

@codecov-commenter
Copy link

codecov-commenter commented Dec 14, 2022

Codecov Report

Base: 76.10% // Head: 75.63% // Decreases project coverage by -0.46% ⚠️

Coverage data is based on head (36dd17a) compared to base (4c9b3a1).
Patch coverage: 76.57% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #876      +/-   ##
==========================================
- Coverage   76.10%   75.63%   -0.47%     
==========================================
  Files         110      114       +4     
  Lines       12698    13221     +523     
==========================================
+ Hits         9664    10000     +336     
- Misses       2490     2645     +155     
- Partials      544      576      +32     
Impacted Files Coverage Δ
pkg/object/mqttproxy/spec.go 100.00% <ø> (ø)
pkg/object/mqttproxy/client.go 77.45% <33.33%> (-4.16%) ⬇️
pkg/object/mqttproxy/mqttproxy.go 46.83% <33.33%> (ø)
pkg/object/mqttproxy/topic.go 47.05% <53.84%> (-52.95%) ⬇️
pkg/object/mqttproxy/sessioncache.go 61.85% <61.85%> (ø)
pkg/object/mqttproxy/session.go 67.70% <68.08%> (-14.51%) ⬇️
pkg/object/mqttproxy/broker.go 74.37% <68.75%> (-0.43%) ⬇️
pkg/object/mqttproxy/cachetopicmgr.go 79.86% <79.86%> (ø)
pkg/object/mqttproxy/nocachetopicmgr.go 92.85% <92.85%> (ø)
pkg/object/mqttproxy/session_manager.go 86.76% <100.00%> (+0.40%) ⬆️
... and 9 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

pkg/object/mqttproxy/broker.go Show resolved Hide resolved
pkg/object/mqttproxy/broker.go Outdated Show resolved Hide resolved
pkg/object/mqttproxy/broker.go Outdated Show resolved Hide resolved
pkg/object/mqttproxy/broker.go Outdated Show resolved Hide resolved
pkg/object/mqttproxy/topicmgr.go Outdated Show resolved Hide resolved
@suchen-sci suchen-sci marked this pull request as draft December 15, 2022 02:10
…ss instance conflict, optim resend time interval, and other updates based on comments
@suchen-sci suchen-sci marked this pull request as ready for review December 15, 2022 09:48
pkg/object/mqttproxy/broker.go Outdated Show resolved Hide resolved
pkg/object/mqttproxy/broker.go Outdated Show resolved Hide resolved
pkg/object/mqttproxy/broker.go Outdated Show resolved Hide resolved
pkg/object/mqttproxy/broker.go Outdated Show resolved Hide resolved
pkg/object/mqttproxy/broker.go Outdated Show resolved Hide resolved
@@ -71,6 +71,9 @@ type (
ConnectionLimit *RateLimit `json:"connectionLimit" jsonschema:"omitempty"`
ClientPublishLimit *RateLimit `json:"clientPublishLimit" jsonschema:"omitempty"`
Rules []*Rule `json:"rules" jsonschema:"omitempty"`
BrokerMode bool `json:"brokerMode" jsonschema:"omitempty"`
Copy link
Collaborator

@zhao-kun zhao-kun Dec 19, 2022

Choose a reason for hiding this comment

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

I prefer to enable the broker model by default because:

  1. The backward-compatible, users can upgrade to the broker model by default, they needn't update their specs.
  2. Broker model has more extensive use cases.

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 am more prefer not to enable it because previous users can upgrade it and the behavior of MQTTProxy stays unchanged unless they update their spec... But I am open to update it.

@localvar localvar merged commit cd42976 into easegress-io:main Dec 22, 2022
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