bytebeamio / rumqtt

The MQTT ecosystem in rust
Apache License 2.0
1.64k stars 252 forks source link

refactor: simplify `Network`with `Framed<.., Codec>` #825

Closed de-sh closed 7 months ago

de-sh commented 8 months ago

As discussed in #814 this simplifies Network using Framed and Codec

Type of change

Checklist:

coveralls commented 8 months ago

Pull Request Test Coverage Report for Build 8346655192

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
rumqttc/src/mqttbytes/mod.rs 0 1 0.0%
rumqttc/src/v5/mqttbytes/mod.rs 0 1 0.0%
rumqttc/src/framed.rs 19 21 90.48%
rumqttc/src/mqttbytes/v4/codec.rs 29 31 93.55%
rumqttc/src/proxy.rs 0 3 0.0%
rumqttc/src/tls.rs 0 3 0.0%
rumqttc/src/mqttbytes/v4/connack.rs 0 6 0.0%
rumqttc/src/v5/mqttbytes/v5/connect.rs 0 6 0.0%
rumqttc/src/v5/mqttbytes/v5/ping.rs 0 6 0.0%
rumqttc/src/v5/mqttbytes/v5/codec.rs 22 31 70.97%
<!-- Total: 274 519 52.79% -->
Files with Coverage Reduction New Missed Lines %
rumqttc/src/lib.rs 1 64.32%
rumqttc/src/mqttbytes/mod.rs 3 86.27%
rumqttc/src/v5/state.rs 5 68.42%
rumqttc/src/state.rs 11 79.36%
rumqttc/src/mqttbytes/v4/pubcomp.rs 18 8.33%
rumqttc/src/mqttbytes/v4/pubrel.rs 18 8.11%
rumqttc/src/mqttbytes/v4/pubrec.rs 18 8.11%
<!-- Total: 74 -->
Totals Coverage Status
Change from base Build 8243857492: -0.3%
Covered Lines: 6239
Relevant Lines: 16624

💛 - Coveralls
de-sh commented 8 months ago

Is there a follow up to this PR already planned?

Thanks for the suggestions, have opened #826 to resolve this, please review!

de-sh commented 7 months ago

Merging this, no functional changes included in this PR

xiaocq2001 commented 7 months ago

After it's merged, some incoming messages disappear in event loop, please help to check.

asyncpubsub_v5 output before the merge:

     Running `target/debug/examples/asyncpubsub_v5`
Event = Incoming(ConnAck(ConnAck { session_present: false, code: Success, properties: Some(ConnAckProperties { session_expiry_interval: None, receive_max: Some(20), max_qos: None, retain_available: None, max_packet_size: None, assigned_client_identifier: None, topic_alias_max: Some(10), reason_string: None, user_properties: [], wildcard_subscription_available: None, subscription_identifiers_available: None, shared_subscription_available: None, server_keep_alive: None, response_information: None, server_reference: None, authentication_method: None, authentication_data: None }) }))
Event = Outgoing(Subscribe(1))
Event = Outgoing(Publish(2))
Event = Incoming(SubAck(SubAck { pkid: 1, return_codes: [Success(AtMostOnce)], properties: None }))
Event = Outgoing(PubRel(2))
Event = Incoming(PubRec(PubRec { pkid: 2, reason: Success, properties: None }))
Event = Incoming(Publish(Publish { dup: false, qos: AtMostOnce, retain: false, topic: b"hello/world", pkid: 0, payload: b"\x01", properties: None }))

asyncpubsub_v5 output after merge:

     Running `target/debug/examples/asyncpubsub_v5`
Event = Incoming(ConnAck(ConnAck { session_present: false, code: Success, properties: Some(ConnAckProperties { session_expiry_interval: None, receive_max: Some(20), max_qos: None, retain_available: None, max_packet_size: None, assigned_client_identifier: None, topic_alias_max: Some(10), reason_string: None, user_properties: [], wildcard_subscription_available: None, subscription_identifiers_available: None, shared_subscription_available: None, server_keep_alive: None, response_information: None, server_reference: None, authentication_method: None, authentication_data: None }) }))
Event = Outgoing(Subscribe(1))
Event = Outgoing(Publish(2))
Event = Outgoing(Publish(3))
Event = Outgoing(Publish(4))
de-sh commented 7 months ago

Thanks for pointing this out @xiaocq2001 there is the lack of a good testsuite for v5, might be a good issue to open!