transport

package
v0.0.0-...-d12d6dc Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package transport defines the interfaces describing a connection-like data transport mechanism.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	io.ReadWriteCloser
	CloseRead() error
	CloseWrite() error
}

Connection is the interface defining a data connection, such as a socket or a mocked implementation.

type MockConnection

type MockConnection struct {
	*io.PipeReader
	*io.PipeWriter
}

MockConnection is a mock implementation of Connection.

func (*MockConnection) Close

func (c *MockConnection) Close() error

Close marks the connection as closed, and closes the read and write channels.

func (*MockConnection) CloseRead

func (c *MockConnection) CloseRead() error

CloseRead closes the read channel.

func (*MockConnection) CloseWrite

func (c *MockConnection) CloseWrite() error

CloseWrite closes the write channel.

type MockTransport

type MockTransport struct {
	// Channel sends connections to the "server" once the "client" has
	// connected.
	Channel chan *MockConnection
}

MockTransport is a mock implementation of Transport.

func (*MockTransport) Dial

func (t *MockTransport) Dial(_ uint32) (Connection, error)

Dial ignores the port, and returns a MockTransport struct.

type Transport

type Transport interface {
	// Dial takes a port number and returns a connected connection.
	Dial(port uint32) (Connection, error)
}

Transport is the interface defining a method of transporting data in a connection-like way. Examples of a Transport implementation could be:

Hyper-V socket transport
TCP/IP socket transport
Mocked-out local transport

type VsockTransport

type VsockTransport struct{}

VsockTransport is an implementation of Transport which uses vsock sockets.

func (*VsockTransport) Dial

func (t *VsockTransport) Dial(port uint32) (Connection, error)

Dial accepts a vsock socket port number as configuration, and returns an unconnected VsockConnection struct.

Jump to

Keyboard shortcuts

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