experiment

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2019 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package experiment contains network experiment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Experiment

type Experiment struct {
	// DoMeasure fills a measurement.
	DoMeasure MeasureFunc

	// Callbacks handles experiment events.
	Callbacks handler.Callbacks

	// Report is the report used by this experiment.
	Report *collector.Report

	// Session is the session to which this experiment belongs.
	Session *session.Session

	// TestName is the experiment name.
	TestName string

	// TestStartTime is the UTC time when the test started.
	TestStartTime string

	// TestVersion is the experiment version.
	TestVersion string
}

Experiment is a network experiment.

func New

func New(
	sess *session.Session, testName, testVersion string, measure MeasureFunc,
) *Experiment

New creates a new experiment. You should not call this function directly rather you should do <package>.NewExperiment where <package> is a subpackage inside of the experiment package, e.g., `.../experiment/ndt7`.

func (*Experiment) CloseReport

func (e *Experiment) CloseReport(ctx context.Context) (err error)

CloseReport closes the open report. This function is idempotent.

func (*Experiment) Measure

func (e *Experiment) Measure(
	ctx context.Context, input string,
) (measurement model.Measurement, err error)

Measure performs a measurement with the specified input. Note that as part of running the measurement, we'll also apply privacy settings. So, the measurement you get back is already scrubbed (if needed).

func (*Experiment) OpenReport

func (e *Experiment) OpenReport(ctx context.Context) (err error)

OpenReport opens a new report for the experiment. This function is idempotent.

func (*Experiment) ReportID

func (e *Experiment) ReportID() string

ReportID returns the report ID or an empty string, if not open.

func (*Experiment) SaveMeasurement

func (e *Experiment) SaveMeasurement(
	measurement model.Measurement, filePath string,
) error

SaveMeasurement saves a measurement on the specified file.

func (*Experiment) SaveMeasurementEx

func (e *Experiment) SaveMeasurementEx(
	measurement model.Measurement, filePath string,
	marshal func(v interface{}) ([]byte, error),
	openFile func(name string, flag int, perm os.FileMode) (*os.File, error),
	write func(fp *os.File, b []byte) (n int, err error),
) error

SaveMeasurementEx is like SaveMeasurement but allows you to mock any operation that SaveMeasurement would perform. You generally want to call SaveMeasurement rather than this function.

func (*Experiment) SubmitMeasurement

func (e *Experiment) SubmitMeasurement(
	ctx context.Context, measurement *model.Measurement,
) error

SubmitMeasurement submits a measurement to the selected collector. It is safe to call this function from different goroutines concurrently as long as the measurement is not shared by the goroutines.

type MeasureFunc

type MeasureFunc func(
	ctx context.Context, sess *session.Session, measurement *model.Measurement,
	callbacks handler.Callbacks,
) error

MeasureFunc is the function that performs a measurement.

Directories

Path Synopsis
Package dash contains the dash network experiment.
Package dash contains the dash network experiment.
Package example contains a simple example of experiment.
Package example contains a simple example of experiment.
Package fbmessenger contains the Facebook Messenger network experiment.
Package fbmessenger contains the Facebook Messenger network experiment.
Package handler contains experiment events handler
Package handler contains experiment events handler
Package hhfm contains the HTTP Header Field Manipulation network experiment.
Package hhfm contains the HTTP Header Field Manipulation network experiment.
Package hirl contains the HTTP Invalid Request Line network experiment.
Package hirl contains the HTTP Invalid Request Line network experiment.
Package httpheader contains code to set common HTTP headers.
Package httpheader contains code to set common HTTP headers.
Package mkevent processes MK events
Package mkevent processes MK events
Package mkhelper contains common code to get the proper helper and configure it into settings.
Package mkhelper contains common code to get the proper helper and configure it into settings.
Package mkrunner contains code to run an MK based test
Package mkrunner contains code to run an MK based test
Package ndt contains the ndt network experiment.
Package ndt contains the ndt network experiment.
Package ndt7 contains the ndt7 network experiment.
Package ndt7 contains the ndt7 network experiment.
Package oodatamodel contains the OONI data model.
Package oodatamodel contains the OONI data model.
Package psiphon implements the psiphon network experiment.
Package psiphon implements the psiphon network experiment.
Package telegram contains the Telegram network experiment.
Package telegram contains the Telegram network experiment.
Package web_connectivity contains the Web Connectivity network experiment.
Package web_connectivity contains the Web Connectivity network experiment.
Package whatsapp contains the WhatsApp network experiment.
Package whatsapp contains the WhatsApp network experiment.

Jump to

Keyboard shortcuts

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