Categorygithub.com/m-lab/ndt7-client-go
modulepackage
0.9.1
Repository: https://github.com/m-lab/ndt7-client-go.git
Documentation: pkg.go.dev

# README

GoDoc Build Status Coverage Status Go Report Card

ndt7 Go client

Reference ndt7 Go client implementation. Useful resources:

The master branch contains stable code. We don't promise we won't break the API, but we'll try not to.

Installing

You need Go >= 1.12. We use modules. Make sure Go knows that:

export GO111MODULE=on

Clone the repository wherever you want with

git clone https://github.com/m-lab/ndt7-client-go

From inside the repository, use go get ./cmd/ndt7-client to build the client. Binaries will be placed in $GOPATH/bin, if GOPATH is set, and in $HOME/go/bin otherwise.

If you're into a one-off install, this

go install -v github.com/m-lab/ndt7-client-go/cmd/ndt7-client@latest

is equivalent to cloning the repository, running go get ./cmd/ndt7-client, and then cancelling the repository directory.

Building with a custom client name

In case you are integrating an ndt7-client binary into a third-party application, it may be useful to build it with a custom client name. Since this value is passed to the server as metadata, doing so will allow you to retrieve measurements coming from your custom integration in Measurement Lab's data easily.

To set a custom client name at build time:

CLIENTNAME=my-custom-client-name

go build -ldflags "-X main.ClientName=$CLIENTNAME" ./cmd/ndt7-client

Prometheus Exporter

While ndt7-client is a "single shot" ndt7 client, there is also a non-interactive periodic test runner ndt7-prometheus-exporter.

Build and Run using Docker

git clone https://github.com/m-lab/ndt7-client-go
docker build -t ndt7-prometheus-exporter .

To run tests repeatedly

PORT=9191
docker run -d -p ${PORT}:8080 ndt7-prometheus-exporter

Sample Prometheus config

# scrape ndt7 test metrics
  - job_name: ndt7
    metrics_path: /metrics
    static_configs:
	  - targets:
	    # host:port of the exporter
	    - localhost:9191

# scrape ndt7-prometheus-exporter itself
  - job_name: ndt7-prometheus-exporter
    static_configs:
	  - targets:
	    # host:port of the exporter
		- localhost:9191

# Packages

No description provided by the author
Package spec contains constants and structs.

# Functions

NewClient creates a new client instance identified by the specified clientName and clientVersion.

# Constants

DefaultWebSocketHandshakeTimeout is the default timeout configured by NewClient in the Client.Dialer.HandshakeTimeout field.

# Variables

ErrNoTargets is returned if all Locate targets have been tried.
ErrServiceUnsupported is returned if an unknown service URL is provided.

# Structs

Client is a ndt7 client.
LatestMeasurements contains the latest Measurement sent by the server and the client, plus the latest ConnectionInfo sent by the server.

# Interfaces

Locator is an interface used to locate a server.