| 1 |
package mqtt |
| 2 |
|
| 3 |
import ( |
| 4 |
"context" |
| 5 |
|
| 6 |
"github.com/eclipse/paho.golang/paho" |
| 7 |
) |
| 8 |
|
| 9 |
// ConnectionManager defines the interface for MQTT connection management. |
| 10 |
type ConnectionManager interface { |
| 11 |
// AwaitConnection waits for the MQTT connection to be established. |
| 12 |
// It blocks until the connection is ready or the context is canceled. |
| 13 |
AwaitConnection(ctx context.Context) error |
| 14 |
|
| 15 |
// Publish sends an MQTT message to the broker. |
| 16 |
// Returns a PublishResponse containing the reason code and any properties, |
| 17 |
// or an error if the publish operation fails. |
| 18 |
Publish(ctx context.Context, publish *paho.Publish) (*paho.PublishResponse, error) |
| 19 |
|
| 20 |
// Disconnect gracefully closes the MQTT connection. |
| 21 |
// It sends a DISCONNECT packet to the broker and waits for the operation |
| 22 |
// to complete or the context to be canceled. |
| 23 |
Disconnect(ctx context.Context) error |
| 24 |
} |