Documentation
¶
Index ¶
- Constants
- func ReadNDTMessage(ws Connection, expectedType MessageType) ([]byte, error)
- func SendJSONMessage(msgType MessageType, msg string, ws Connection) error
- func SendMetrics(metrics *web100.Metrics, ws Connection) error
- func WriteNDTMessage(ws Connection, msgType MessageType, msg fmt.Stringer) error
- type Connection
- type JSONMessage
- type Measurable
- type MeasuredConnection
- type MessageType
Constants ¶
const ( // SrvQueue signals how long a client should wait. SrvQueue = MessageType(1) // MsgLogin is used for signalling capabilities. MsgLogin = MessageType(2) // TestPrepare indicates that the server is getting ready to run a test. TestPrepare = MessageType(3) // TestStart indicates prepapartion is complete and the test is about to run. TestStart = MessageType(4) // TestMsg is used for communication during a test. TestMsg = MessageType(5) // TestFinalize is the last message a test sends. TestFinalize = MessageType(6) // MsgError is sent when an error occurs. MsgError = MessageType(7) // MsgResults sends test results. MsgResults = MessageType(8) // MsgLogout is used to logout. MsgLogout = MessageType(9) // MsgWaiting is used for queue management. MsgWaiting = MessageType(10) // MsgExtendedLogin is used to signal advanced (now required) capabilities. MsgExtendedLogin = MessageType(11) )
Variables ¶
This section is empty.
Functions ¶
func ReadNDTMessage ¶
func ReadNDTMessage(ws Connection, expectedType MessageType) ([]byte, error)
ReadNDTMessage reads a single NDT message out of the connection.
func SendJSONMessage ¶
func SendJSONMessage(msgType MessageType, msg string, ws Connection) error
SendJSONMessage writes a single NDT message in JSON format.
func SendMetrics ¶
func SendMetrics(metrics *web100.Metrics, ws Connection) error
SendMetrics sends all the required properties out along the NDT control channel.
func WriteNDTMessage ¶
func WriteNDTMessage(ws Connection, msgType MessageType, msg fmt.Stringer) error
WriteNDTMessage write a single NDT message to the connection.
Types ¶
type Connection ¶
type Connection interface {
ReadMessage() (_ int, p []byte, err error) // The first value in the returned tuple should be ignored. It is included in the API for websocket.Conn compatibility.
WriteMessage(messageType int, data []byte) error
DrainUntil(t time.Time) (bytesRead int64, err error)
FillUntil(t time.Time, buffer []byte) (bytesWritten int64, err error)
Close() error
}
Connection is a general system over which we might be able to read an NDT message. It contains a subset of the methods of websocket.Conn, in order to allow non-websocket-based NDT tests in support of legacy clients, along with the new methods "DrainUntil" and "FillUntil".
type JSONMessage ¶
JSONMessage holds the JSON messages we can receive from the server. We only support the subset of the NDT JSON protocol that has two fields: msg, and tests.
func ReceiveJSONMessage ¶
func ReceiveJSONMessage(ws Connection, expectedType MessageType) (*JSONMessage, error)
ReceiveJSONMessage reads a single NDT message in JSON format.
func (*JSONMessage) String ¶
func (n *JSONMessage) String() string
String serializes the message to a string.
type Measurable ¶
type Measurable interface {
StartMeasuring(ctx context.Context)
StopMeasuring() (*web100.Metrics, error)
}
Measurable things can be measured over a given timeframe.
type MeasuredConnection ¶
type MeasuredConnection interface {
Connection
Measurable
}
MeasuredConnection is a connection which can also be measured.
func AdaptNetConn ¶
func AdaptNetConn(conn net.Conn, input io.Reader) MeasuredConnection
AdaptNetConn turns a non-WS-based TCP connection into a protocol.MeasuredConnection.
func AdaptWsConn ¶
func AdaptWsConn(ws *websocket.Conn) MeasuredConnection
AdaptWsConn turns a websocket Connection into a struct which implements both Measurer and Connection
type MessageType ¶
type MessageType byte
MessageType is the full set opf NDT protocol messages we understand.
func (MessageType) String ¶
func (m MessageType) String() string