diff options
author | Ethel Morgan <eth@ethulhu.co.uk> | 2020-06-24 23:21:32 +0100 |
---|---|---|
committer | Ethel Morgan <eth@ethulhu.co.uk> | 2020-06-24 23:21:32 +0100 |
commit | e825e6820389fab7c97ae3665155401124ab8ecf (patch) | |
tree | f8b15365e51b2f0c8de73215ac5fb5ab14cecdb0 /api.go | |
parent | 9ccb33b03d4d2ac71fe0f1fec1ee0a64cca157f5 (diff) |
make Client an interface, make Message a plain structv0.0.3
Diffstat (limited to 'api.go')
-rw-r--r-- | api.go | 30 |
1 files changed, 30 insertions, 0 deletions
@@ -0,0 +1,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) +) |