tools

package module
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2016 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

gomqtt/tools

Build Status Coverage Status GoDoc Release Go Report Card

Package tools implements utilities for building MQTT 3.1.1 components.

Installation

Get it using go's standard toolset:

$ go get github.com/gomqtt/tools

Documentation

Overview

Package tools implements utilities for building MQTT 3.1.1 (http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/) components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn added in v0.7.0

type Conn interface {
	Send(pkt packet.Packet) error
	Receive() (packet.Packet, error)
	Close() error
}

A Conn defines an abstract interface for connections used with a Flow.

type Counter added in v0.6.0

type Counter struct {
	// contains filtered or unexported fields
}

A Counter continuously counts packet ids.

func NewCounter added in v0.6.0

func NewCounter() *Counter

NewCounter returns a new counter.

func (*Counter) Next added in v0.6.0

func (c *Counter) Next() uint16

Next will return the next id.

func (*Counter) Reset added in v0.6.0

func (c *Counter) Reset()

Reset will reset the counter.

type Flow added in v0.6.0

type Flow struct {
	// contains filtered or unexported fields
}

A Flow is a sequence of actions that can be tested against a connection.

func NewFlow added in v0.6.0

func NewFlow() *Flow

NewFlow returns a new flow.

func (*Flow) Close added in v0.6.0

func (f *Flow) Close() *Flow

Close will immediately close the connection.

func (*Flow) Delay added in v0.6.0

func (f *Flow) Delay(d time.Duration) *Flow

Delay will suspend the flow using the specified duration.

func (*Flow) End added in v0.6.0

func (f *Flow) End() *Flow

End will match proper connection close.

func (*Flow) Receive added in v0.6.0

func (f *Flow) Receive(pkt packet.Packet) *Flow

Receive will receive and match one packet.

func (*Flow) Run added in v0.6.0

func (f *Flow) Run(fn func()) *Flow

Run will call the supplied function and wait until it returns.

func (*Flow) Send added in v0.6.0

func (f *Flow) Send(pkt packet.Packet) *Flow

Send will send and one packet.

func (*Flow) Skip added in v0.6.0

func (f *Flow) Skip() *Flow

Skip will receive one packet without matching it.

func (*Flow) Test added in v0.6.0

func (f *Flow) Test(t *testing.T, conn Conn)

Test starts the flow on the given Conn and reports to the specified test.

func (*Flow) Wait added in v0.6.0

func (f *Flow) Wait(ch chan struct{}) *Flow

Wait will wait until the specified channel is closed.

type Pipe added in v0.7.0

type Pipe struct {
	// contains filtered or unexported fields
}

The Pipe pipes packets from Send to Receive.

func NewPipe added in v0.7.0

func NewPipe() *Pipe

NewPipe returns a new Pipe.

func (*Pipe) Close added in v0.7.0

func (conn *Pipe) Close() error

Close will close the conn and let Send and Receive return errors.

func (*Pipe) Receive added in v0.7.0

func (conn *Pipe) Receive() (packet.Packet, error)

Receive returns the packet being sent with Send.

func (*Pipe) Send added in v0.7.0

func (conn *Pipe) Send(pkt packet.Packet) error

Send returns packet on next Receive call.

type Queue added in v0.7.0

type Queue struct {
	// contains filtered or unexported fields
}

Queue is a basic FIFO queue for Messages.

func NewQueue added in v0.7.0

func NewQueue(maxSize int) *Queue

NewQueue returns a new Queue. If maxSize is greater than zero the queue will not grow more than the defined size.

func (*Queue) All added in v0.7.0

func (q *Queue) All() []*packet.Message

All returns and removes all messages from the queue.

func (*Queue) Len added in v0.7.0

func (q *Queue) Len() int

Len returns the length of the queue.

func (*Queue) Pop added in v0.7.0

func (q *Queue) Pop() *packet.Message

Pop removes and returns a message from the queue in first to last order.

func (*Queue) Push added in v0.7.0

func (q *Queue) Push(msg *packet.Message)

Push adds a message to the queue.

type Store added in v0.6.0

type Store struct {
	// contains filtered or unexported fields
}

The Store is a thread-safe packet store.

func NewStore added in v0.6.0

func NewStore() *Store

NewStore returns a new Store.

func (*Store) All added in v0.6.0

func (s *Store) All(prefix string) []packet.Packet

All will return all packets currently saved in the store.

func (*Store) Delete added in v0.6.0

func (s *Store) Delete(prefix string, id uint16)

Delete will remove a packet from the store.

func (*Store) Lookup added in v0.6.0

func (s *Store) Lookup(prefix string, id uint16) packet.Packet

Lookup will retrieve a packet from the store.

func (*Store) Reset added in v0.6.0

func (s *Store) Reset()

Reset will reset the store.

func (*Store) Save added in v0.6.0

func (s *Store) Save(prefix string, pkt packet.Packet)

Save will store a packet in the store. An eventual existing packet with the same id gets quietly overwritten.

type Tree

type Tree struct {
	// The separator character. Default: "/"
	Separator string

	// The single level wildcard character. Default: "+"
	WildcardOne string

	// The multi level wildcard character. Default "#"
	WildcardSome string
	// contains filtered or unexported fields
}

A Tree implements a thread-safe topic tree.

func NewTree

func NewTree() *Tree

NewTree returns a new Tree.

func (*Tree) Add

func (t *Tree) Add(topic string, value interface{})

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 added in v0.4.0

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) Empty

func (t *Tree) Empty(topic string)

Empty will unregister all values from the supplied topic. This function will automatically shrink the tree.

func (*Tree) Match

func (t *Tree) Match(topic string) []interface{}

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 added in v0.7.0

func (t *Tree) MatchFirst(topic string) interface{}

MatchFirst will run Match and return the first value or nil.

func (*Tree) Remove

func (t *Tree) Remove(topic string, value interface{})

Remove unregisters the value from the supplied topic. This function will automatically shrink the tree.

func (*Tree) Reset

func (t *Tree) Reset()

Reset will completely clear the tree.

func (*Tree) Search added in v0.3.0

func (t *Tree) Search(topic string) []interface{}

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 added in v0.7.0

func (t *Tree) SearchFirst(topic string) interface{}

SearchFirst will run Search and return the first value or nil.

func (*Tree) Set added in v0.3.0

func (t *Tree) Set(topic string, value interface{})

Set sets the supplied value as the only value for the supplied topic. This function will automatically grow the tree.

func (*Tree) String

func (t *Tree) String() string

String will return a string representation of the tree.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL