Documentation
¶
Overview ¶
Package ndt7 contains a ndt7 client.
The client will automatically discover a suitable server to use by default. However, you can also manually discover a server and configure the client accordingly.
The code configures reasonable I/O timeouts. We recommend to also provide contexts with whole-operation timeouts attached, as we do in the code example provided as part of this package.
Example ¶
This shows how to run a ndt7 test.
package main
import (
"context"
"log"
"time"
"github.com/m-lab/ndt7-client-go"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
defer cancel()
client := ndt7.NewClient("ndt7-client-go-example", "0.1.0")
ch, err := client.StartDownload(ctx)
if err != nil {
log.Fatal(err)
}
for ev := range ch {
log.Printf("%+v", ev)
}
ch, err = client.StartUpload(ctx)
if err != nil {
log.Fatal(err)
}
for ev := range ch {
log.Printf("%+v", ev)
}
}
Output:
Index ¶
Examples ¶
Constants ¶
const DefaultWebSocketHandshakeTimeout = 7 * time.Second
DefaultWebSocketHandshakeTimeout is the default timeout configured by NewClient in the Client.Dialer.HandshakeTimeout field.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// ClientName is the name of the software running ndt7 tests. It's set by
// NewClient; you may want to change this value.
ClientName string
// ClientVersion is the version of the software running ndt7 tests. It's
// set by NewClient; you may want to change this value.
ClientVersion string
// Dialer is the optional websocket Dialer. It's set to its
// default value by NewClient; you may override it.
Dialer websocket.Dialer
// FQDN is the optional server FQDN. We will discover the FQDN of
// a nearby M-Lab server for you if this field is empty.
FQDN string
// MLabNSClient is the mlabns client. We'll configure it with
// defaults in NewClient and you may override it.
MLabNSClient *mlabns.Client
// Scheme is the scheme to use. It's set to "wss" by NewClient,
// change it to "ws" for unencrypted ndt7.
Scheme string
// contains filtered or unexported fields
}
Client is a ndt7 client.
func NewClient ¶
NewClient creates a new client instance identified by the specified clientName and clientVersion. M-Lab services may reject requests coming from clients that do not identify themselves properly.
func (*Client) StartDownload ¶
StartDownload discovers a ndt7 server (if needed) and starts a download. On success it returns a channel where measurements are emitted. This channel is closed when the download ends. On failure, the error is non nil and you should not attempt using the channel. A side effect of starting the download is that, if you did not specify a server FQDN, we will discover a server for you and store that value into the c.FQDN field.
func (*Client) StartUpload ¶
StartUpload is like StartDownload but for the upload.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
ndt7-client
command
ndt7-client is the ndt7 command line client.
|
ndt7-client is the ndt7 command line client. |
|
ndt7-client/internal/emitter
Package emitter contains the ndt7-client emitter.
|
Package emitter contains the ndt7-client emitter. |
|
ndt7-client/internal/mocks
Package mocks contains mocks
|
Package mocks contains mocks |
|
internal
|
|
|
download
Package download contains ndt7 download code.
|
Package download contains ndt7 download code. |
|
mocks
Package mocks implements mocks.
|
Package mocks implements mocks. |
|
params
Package params contains private constants and structs.
|
Package params contains private constants and structs. |
|
upload
Package upload contains ndt7 upload code
|
Package upload contains ndt7 upload code |
|
websocketx
Package websocketx contains websocket extensions.
|
Package websocketx contains websocket extensions. |
|
Package mlabns implements a simple mlab-ns client.
|
Package mlabns implements a simple mlab-ns client. |
|
Package spec contains constants and structs.
|
Package spec contains constants and structs. |