Documentation ¶
Overview ¶
Package topic implements common methods to handle MQTT topics.
Index ¶
- Variables
- func ContainsWildcards(topic string) bool
- func Parse(topic string, allowWildcards bool) (string, error)
- type Tree
- func (t *Tree) Add(topic string, value interface{})
- func (t *Tree) All() []interface{}
- func (t *Tree) Clear(value interface{})
- func (t *Tree) Count() int
- func (t *Tree) Empty(topic string)
- func (t *Tree) Get(topic string) []interface{}
- func (t *Tree) Match(topic string) []interface{}
- func (t *Tree) MatchFirst(topic string) interface{}
- func (t *Tree) Remove(topic string, value interface{})
- func (t *Tree) Reset()
- func (t *Tree) Search(topic string) []interface{}
- func (t *Tree) SearchFirst(topic string) interface{}
- func (t *Tree) Set(topic string, value interface{})
- func (t *Tree) String() string
Constants ¶
This section is empty.
Variables ¶
var ErrWildcards = errors.New("invalid use of wildcards")
ErrWildcards is returned by Parse if a topic contains invalid wildcards.
var ErrZeroLength = errors.New("zero length topic")
ErrZeroLength is returned by Parse if a topics has a zero length.
Functions ¶
func ContainsWildcards ¶
ContainsWildcards tests if the supplied topic contains wildcards. The topic is expected to be tested and normalized using Parse beforehand.
Types ¶
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
A Tree implements a thread-safe topic tree.
func NewStandardTree ¶ added in v0.13.0
func NewStandardTree() *Tree
NewStandardTree returns a new Tree using the standard MQTT separator and wildcards.
func (*Tree) Add ¶
Add registers the value for the supplied topic. This function will automatically grow the tree. If value already exists for the given topic it will not be added again.
func (*Tree) All ¶
func (t *Tree) All() []interface{}
All will return all stored values in the tree.
func (*Tree) Clear ¶
func (t *Tree) Clear(value interface{})
Clear will unregister the supplied value from all topics. This function will automatically shrink the tree.
func (*Tree) Count ¶
Count will count all stored values in the tree. It will not filter out duplicate values and thus might return a different result to `len(All())`.
func (*Tree) Empty ¶
Empty will unregister all values from the supplied topic. This function will automatically shrink the tree.
func (*Tree) Match ¶
Match will return a set of values from topics that match the supplied topic. The result set will be cleared from duplicate values.
Note: In contrast to Search, Match does not respect wildcards in the query but in the stored tree.
func (*Tree) MatchFirst ¶
MatchFirst behaves similar to Match but only returns the first found value.
func (*Tree) Remove ¶
Remove un-registers the value from the supplied topic. This function will automatically shrink the tree.
func (*Tree) Search ¶
Search will return a set of values from topics that match the supplied topic. The result set will be cleared from duplicate values.
Note: In contrast to Match, Search respects wildcards in the query but not in the stored tree.
func (*Tree) SearchFirst ¶
SearchFirst behaves similar to Search but only returns the first found value.