-
Notifications
You must be signed in to change notification settings - Fork 26
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
Scetch a possiblity for custom logic in the broker #47
base: main
Are you sure you want to change the base?
Conversation
@bschwind a quick attempt how to plug custom logic into the broker - no logic implemented - just to get the discussion started. Thanks for comments! |
c3df8c0
to
7fcf178
Compare
Hey @flxo, sorry for the late response! Been on holiday the past week, but I'll try to take a look at this soon. |
@bschwind Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flxo thanks for the work so far! I saw you originally were using async trait methods (via the async-trait
crate), what was your reasoning for switching away from it?
It's not that I'm for or against it, just curious about the reasoning. I think that will be a big decision for us - do we want to allow async operations in the plugins? I can imagine a plugin that would want to read from a database or key-value store before making a decision, so it might be nicer to have the functions be async. I haven't thought through all the implications yet.
I looked less at the logic changes in broker.rs
as I think settling on the API design first is important.
I left some more targeted comments in the code itself. Thanks again!
fn on_subscribe(&mut self, packet: &SubscribePacket) -> SubscribeAckPacket; | ||
|
||
/// Called on publish packets reception for QoS 0. Return true if the packet should be published to the clients. | ||
fn on_publish_received_qos0(&mut self, packet: &PublishPacket) -> bool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reasoning for splitting out publishes based on the qos? PublishPacket
already has the qos
field on it, but maybe there's some other reasoning for it that I'm missing.
Is this for handling the individual steps in the QoS sending handshake, or just a wholesale "We received a qos2 packet, do you want to send it?"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a single "callback" for publication but struggled with the return type. There's no return for QOS0, a Publish Ack for QOS1 and PublishReceivedAck for QOS2.
I'm fine with merging those if you want and but would require to define a struct for that the includes basically the same as the PublishAckPacket
and PublishReceivedPacket
in an Option
.
The reason why I used the I will try to answer your findings inline. |
Some thoughts about a broker plugins
@flxo still keeping an eye on this PR! Sorry though that I don't have the bandwidth for quick reviews. I'll be happy to give it a look when you think it's ready for another review. |
Thanks. I'll try to solve some of the todos I left in the PR and will ping you. |
Collect unauthorized connections seperated from the session until the auth is complete. Introduce a unique identifier for connections.
Replace String connection id with cheaper u64. The connection id is a atomically inremented counter in the client handler.
@bschwind I refactored the connection handling a bit and separated the unauthenticated connections from the session. Introduced a I'd love to hear your feedback. |
Hi @flxo Sorry for the long time radio silence. I still think this is good work, but I don't have enough bandwidth to review this in any sort of timely fashion. I plan to get back into this project around the time when I update my ESP32 projects to use Rust, but until then you probably won't see too much activity from me on it. I would recommend working with either your fork of this repo, or rumqtt (which I would guess is farther along and has more contributors) |
Use the authentication stuff as an example how customer code could be plugged into the broker. The authentification is not implemented - it's all just about how to proceed...
The concrete type that impls the authentication has the advantage of static dispatch. There ware probably other traits needed for intercepting publishes and subscriptions e.g