The goal is use Mqtt with actors.
While using ports and adpates ( a.k.a. hexagonal architecture) we may want to use actix actors to implement the core. Specially if multiple protocols are to be used.
If one of those protocols is MQTT then this is the adapter you need.
This crate is asyncrhonous and should be run within actix_rs
executor.
Tough the name suggest this crate is about implementing the adapter as an actor, actually is not pure actor.
It has an actor to let you have an address to allow the core sending messages to topics: MqttPublisher
, but the main job is carried by the struct: MqttConnectionManager
, including connecting to the server and creating the former actor.
```plantuml
@startuml
package mqttactor {
struct MqttConnectionManager{
from(..) -> Self
addsubscription(..)
start()
getPublisher()
}
annotation MqttPublisher
struct MqttPublisherActor
struct MqttPublisherActormock #gray
interface Subscription
'struct DumpHandler #white
'Struct EchoHandler #white
'struct "echoHandler
MqttConnectionManager *-- MqttPublisher: publisher_actor
MqttPublisher <|-- MqttPublisherActor
MqttPublisher <|-- MqttPublisherActor_mock : <<unit test>>
'Subscription <|-- DumpHandler
'Subscription <|-- EchoHandler
'MqttPublisher ..|> strmsg : implement
'EchoHandler --> strmsg: calls
}
struct yourSubscription
yourSubscription --|> Subscription
yourSubscription --* MqttConnectionManager : 0:N
struct yourActor #white
yourSubscription -> yourActor: can call
struct "your Handler <Handler<yourMessage>>" as message
MqttPublisher ..|> message : implement
yourActor --> message: can call
@enduml ```