flow

package
v0.14.3 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2020 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Overview

Package flow can be used to test MQTT packet flows.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn interface {
	Send(pkt packet.Generic, async bool) error
	Receive() (packet.Generic, error)
	Close() error
}

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

type Flow

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

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

func New

func New() *Flow

New returns a new flow.

func (*Flow) Close

func (f *Flow) Close() *Flow

Close will immediately close the connection.

func (*Flow) Debug added in v0.6.0

func (f *Flow) Debug() *Flow

Debug will activate the debug mode.

func (*Flow) End

func (f *Flow) End() *Flow

End will match proper connection close.

func (*Flow) Receive

func (f *Flow) Receive(pkts ...packet.Generic) *Flow

Receive will receive and match the specified packets out of order.

func (*Flow) Run

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

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

func (*Flow) Send

func (f *Flow) Send(pkts ...packet.Generic) *Flow

Send will send the specified packets.

func (*Flow) Skip

func (f *Flow) Skip(pkts ...packet.Generic) *Flow

Skip will receive the specified packets without matching out of order.

func (*Flow) Test

func (f *Flow) Test(conn Conn) error

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

func (*Flow) TestAsync

func (f *Flow) TestAsync(conn Conn, timeout time.Duration) <-chan error

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

type Pipe

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

The Pipe pipes packets from Send to Receive.

func NewPipe

func NewPipe() *Pipe

NewPipe returns a new Pipe.

func (*Pipe) Close

func (conn *Pipe) Close() error

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

func (*Pipe) Receive

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

Receive returns the packet being sent with Send.

func (*Pipe) Send

func (conn *Pipe) Send(pkt packet.Generic, _ bool) error

Send returns packet on next Receive call.

Jump to

Keyboard shortcuts

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