netiotest

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BenchmarkStreamClientDialServerHandle

func BenchmarkStreamClientDialServerHandle(
	b *testing.B,
	newClient func(psc *PipeStreamClient) netio.StreamClient,
	server netio.StreamServer,
)

BenchmarkStreamClientDialServerHandle tests the performance of the stream client and server establishing and closing connections.

func BenchmarkStreamClientServer

func BenchmarkStreamClientServer(
	b *testing.B,
	newClient func(psc *PipeStreamClient) netio.StreamClient,
	server netio.StreamServer,
	writeSize int,
)

BenchmarkStreamClientServer tests the performance of the stream client and server connections.

func TestConnPairRoundTrip

func TestConnPairRoundTrip(t *testing.T, newConnPair func() (c1, c2 netio.Conn))

TestConnPairRoundTrip tests a pair of connections for round-trip communication.

func TestPreambleStreamClientServerProceed

func TestPreambleStreamClientServerProceed(
	t *testing.T,
	newClient func(psc *PipeStreamClient) netio.StreamClient,
	server netio.StreamServer,
	expectedServerAddr conn.Addr,
	expectedUsername string,
)

TestPreambleStreamClientServerProceed tests a pair of stream client and server implementations that, after performing whatever protocol-specific handshake, simply return the underlying connection to the caller.

func TestStreamClientServerAbort

func TestStreamClientServerAbort(
	t *testing.T,
	newClient func(psc *PipeStreamClient) netio.StreamClient,
	server netio.StreamServer,
	checkDialErr func(t *testing.T, dialResult conn.DialResult, err error),
)

TestStreamClientServerAbort tests a pair of stream client and server implementations for handling aborted connection requests.

func TestWrapConnStreamClientServerProceed

func TestWrapConnStreamClientServerProceed(
	t *testing.T,
	newClient func(psc *PipeStreamClient) netio.StreamClient,
	server netio.StreamServer,
	expectedServerAddr conn.Addr,
	expectedUsername string,
)

TestWrapConnStreamClientServerProceed tests a pair of stream client and server implementations that return wrapper connections over the underlying connection.

Types

type PipeConn

type PipeConn struct {
	*netio.PipeConn
	// contains filtered or unexported fields
}

PipeConn is *netio.PipeConn with additional local and remote addresses.

func (*PipeConn) LocalConnAddr

func (c *PipeConn) LocalConnAddr() conn.Addr

LocalConnAddr returns the local address of the connection, if known.

func (*PipeConn) RemoteConnAddr

func (c *PipeConn) RemoteConnAddr() conn.Addr

RemoteConnAddr returns the remote address of the connection, if known.

type PipeStreamClient

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

PipeStreamClient handles stream connection requests by creating a pipe for each DialStream call and sending the server end to a channel.

func NewPipeStreamClient

func NewPipeStreamClient(info netio.StreamDialerInfo) (*PipeStreamClient, <-chan *PipeConn)

NewPipeStreamClient returns a new *PipeStreamClient and a channel for receiving server ends of the pipes.

func (*PipeStreamClient) Close

func (c *PipeStreamClient) Close() error

Close closes the pipe channel.

func (*PipeStreamClient) DialStream

func (c *PipeStreamClient) DialStream(ctx context.Context, addr conn.Addr, payload []byte) (plc netio.Conn, err error)

DialStream implements netio.StreamDialer.DialStream.

func (*PipeStreamClient) NewStreamDialer

func (c *PipeStreamClient) NewStreamDialer() (netio.StreamDialer, netio.StreamDialerInfo)

NewStreamDialer implements netio.StreamClient.NewStreamDialer.

Jump to

Keyboard shortcuts

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