aboutsummaryrefslogtreecommitdiff
path: root/api.go
blob: 8397cb9d6ba6f20ce0831b459ee58c95dbc0c3b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// SPDX-FileCopyrightText: 2020 Ethel Morgan
//
// SPDX-License-Identifier: MIT

// Package catbus is a convenience wrapper around MQTT for use with Catbus.
package catbus

type (
	MessageHandler func(Client, Message)

	Message struct {
		Payload   string
		Retention Retention
		Topic     string
	}

	Client interface {
		Connect() error
		Subscribe(topic string, f MessageHandler) error
		Publish(topic string, retention Retention, payload string) error
	}

	// Retention is whether or not the MQTT broker should retain the message.
	Retention bool
)

const (
	Retain     = Retention(true)
	DontRetain = Retention(false)
)