flow

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2018 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.GenericPacket) error
	Receive() (packet.GenericPacket, 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) Delay

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

Delay will suspend the flow using the specified duration.

func (*Flow) End

func (f *Flow) End() *Flow

End will match proper connection close.

func (*Flow) Receive

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

Receive will receive and match one packet.

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(pkt packet.GenericPacket) *Flow

Send will send and one packet.

func (*Flow) Skip

func (f *Flow) Skip() *Flow

Skip will receive one packet without matching it.

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.

func (*Flow) Wait

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

Wait will wait until the specified channel is closed.

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.GenericPacket, error)

Receive returns the packet being sent with Send.

func (*Pipe) Send

func (conn *Pipe) Send(pkt packet.GenericPacket) 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