fakesocket

package
v0.0.0-...-7a0dfb2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyClosedConnection = errors.New("connection is already closed")
View Source
var ErrClosedConnection = errors.New("connection is closed")
View Source
var FakeAddr = &net.UDPAddr{
	IP:   net.IPv4(127, 0, 0, 1),
	Port: 8181,
}

FakeAddr is a fake net.Addr

View Source
var FakeMetric = []byte("foo.bar.baz:2|c")

FakeMetric is a fake metric.

Functions

func Factory

func Factory() (net.PacketConn, error)

Factory is a replacement for net.ListenPacket() that produces instances of FakeRandomPacketConn.

func NewCountedFakePacketConn

func NewCountedFakePacketConn(limit uint64) (net.PacketConn, chan struct{})

func NewFakePacketConn

func NewFakePacketConn() net.PacketConn

Types

type FakePacketConn

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

FakePacketConn is a fake net.PacketConn (and net.Conn) providing FakeMetric when read from.

func (*FakePacketConn) Close

func (fpc *FakePacketConn) Close() error

Close dummy impl.

func (*FakePacketConn) LocalAddr

func (fpc *FakePacketConn) LocalAddr() net.Addr

LocalAddr dummy impl.

func (*FakePacketConn) Read

func (fpc *FakePacketConn) Read(b []byte) (int, error)

Read copies FakeMetric into b To satisfy net.Conn

func (*FakePacketConn) ReadFrom

func (fpc *FakePacketConn) ReadFrom(b []byte) (int, net.Addr, error)

ReadFrom copies FakeMetric into b.

func (*FakePacketConn) RemoteAddr

func (fpc *FakePacketConn) RemoteAddr() net.Addr

RemoteAddr dummy impl. To satisfy net.Conn

func (*FakePacketConn) SetDeadline

func (fpc *FakePacketConn) SetDeadline(t time.Time) error

SetDeadline dummy impl.

func (*FakePacketConn) SetReadDeadline

func (fpc *FakePacketConn) SetReadDeadline(t time.Time) error

SetReadDeadline dummy impl.

func (*FakePacketConn) SetWriteDeadline

func (fpc *FakePacketConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline dummy impl.

func (*FakePacketConn) Write

func (fpc *FakePacketConn) Write(b []byte) (int, error)

WriteTo dummy impl. To satisfy net.Conn

func (*FakePacketConn) WriteTo

func (fpc *FakePacketConn) WriteTo(b []byte, addr net.Addr) (int, error)

WriteTo dummy impl.

type FakeRandomPacketConn

type FakeRandomPacketConn struct {
	FakePacketConn
}

FakeRandomPacketConn is a fake net.PacketConn providing random fake metrics.

func (*FakeRandomPacketConn) ReadFrom

func (frpc *FakeRandomPacketConn) ReadFrom(b []byte) (int, net.Addr, error)

ReadFrom generates random metric and writes in into b.

Jump to

Keyboard shortcuts

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