modelx

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package modelx contains the data model.

This package will be merged into github.com/ooni/probe-cli/v3/internal/model.

Index

Constants

This section is empty.

Variables

View Source
var ErrLocationChanged = errors.New("location has changed")

ErrLocationChanged indicates that the location has changed.

Functions

This section is empty.

Types

type InterpreterCommand added in v0.2.0

type InterpreterCommand struct {
	// RunCommand is the name of the command to run.
	RunCommand string `json:"run_command"`

	// WithArguments contains the command arguments.
	WithArguments json.RawMessage `json:"with_arguments"`
}

InterpreterCommand is a command interpreted by the interpreter.

type InterpreterConfig added in v0.2.0

type InterpreterConfig struct {
	// TestHelpers contains test helpers information.
	TestHelpers map[string][]model.OOAPIService `json:"test_helpers"`
}

InterpreterConfig contains configuration for running the interpreter.

type InterpreterLocation added in v0.2.0

type InterpreterLocation interface {
	// IPv4 returns the IPv4 location.
	IPv4() optional.Value[*Location]

	// IPv6 returns the IPv6 location.
	IPv6() optional.Value[*Location]

	// Refresh attempts to refresh the location and returns an error
	// on failure or when the location has changed.
	Refresh() error
}

InterpreterLocation is the interpreter notion of location.

type InterpreterNettestRunArguments

type InterpreterNettestRunArguments struct {
	// Annotations contains extra annotations.
	Annotations map[string]string `json:"annotations"`

	// ExperimentalFlags contains experimental flags.
	ExperimentalFlags map[string]bool `json:"experimental_flags"`

	// NettestName is the nettest name.
	NettestName string `json:"nettest_name"`

	// ReportID is the report ID.
	ReportID string `json:"report_id"`

	// SuiteName is the suite to which this nettest belongs.
	SuiteName string `json:"suite_name"`

	// Targets contains experiment specific targets.
	Targets json.RawMessage `json:"targets"`
}

InterpreterNettestRunArguments contains arguments for the nettest/run command.

type InterpreterSaver added in v0.2.0

type InterpreterSaver interface {
	// SaveMeasurement saves the given measurement, which typically
	// implies uploading it to the backend and updating the DB.
	SaveMeasurement(ctx context.Context, meas *model.Measurement) error
}

InterpreterSaver is the interpreter view of the interface allowing us to save/submit measurements.

type InterpreterScript

type InterpreterScript struct {
	// Config contains global configuration for the interpreter.
	Config InterpreterConfig `json:"config"`

	// Commands contains the list of commands to execute.
	Commands []InterpreterCommand `json:"commands"`
}

InterpreterScript is the script for the interpreter.

type InterpreterSettings added in v0.2.0

type InterpreterSettings interface {
	// IsNettestEnabled returns true if a nettest is enabled.
	IsNettestEnabled(name string) bool

	// IsSuiteEnabled returns true if a suite is enabled.
	IsSuiteEnabled(name string) bool

	// MaxRuntime returns the maximum runtime for nettests that take
	// multiple targets such as Web Connectivity.
	MaxRuntime() time.Duration
}

InterpreterSettings abstracts OONI Probe settings for the interpreter.

type InterpreterUISetProgressBarRangeArguments added in v0.2.0

type InterpreterUISetProgressBarRangeArguments struct {
	// InitialValue is the progress bar initial value.
	InitialValue float64 `json:"initial_value"`

	// MaxValue is the progress bar maximum value.
	MaxValue float64 `json:"max_value"`

	// SuiteName is the name of the suite that is running.
	SuiteName string `json:"suite_name"`
}

InterpreterUISetProgressBarRangeArguments contains arguments for the ui/set_progress_bar_range command.

type InterpreterUISetProgressBarValueArguments added in v0.2.0

type InterpreterUISetProgressBarValueArguments struct {
	// SuiteName is the name of the suite that is running.
	SuiteName string `json:"suite_name"`

	// Value is the absolute progress bar value.
	Value float64 `json:"value"`
}

InterpreterUISetProgressBarValueArguments contains arguments for the ui/set_progress_bar_value command.

type InterpreterUISetSuiteArguments added in v0.2.0

type InterpreterUISetSuiteArguments struct {
	// SuiteName is the name of the suite that is running.
	SuiteName string `json:"suite_name"`
}

InterpreterUISetSuiteArguments contains arguments for the ui/set_suite command.

type InterpreterView added in v0.2.0

type InterpreterView interface {
	// UpdateNettestName updates the name of the running nettest.
	//
	// This method MUST be CONCURRENCY SAFE.
	UpdateNettestName(name string)

	// UpdateProgressBarRange updates the progress bar growth range.
	//
	// This method MUST be CONCURRENCY SAFE.
	UpdateProgressBarRange(minimum, maximum float64)

	// UpdateProgressBarValueAbsolute updates the absolute value of the
	// progress bar disregarding the range set using UpdateProgressBarRange.
	//
	// This method MUST be CONCURRENCY SAFE.
	UpdateProgressBarValueAbsolute(value float64)

	// UpdateProgressBarValueWithinRange updates the progress bar value
	// scaling it within the range set with UpdateProgressBarRange.
	//
	// This method MUST be CONCURRENCY SAFE.
	UpdateProgressBarValueWithinRange(value float64)

	// UpdateSuiteName updates the name of the running suite.
	//
	// This method MUST be CONCURRENCY SAFE.
	UpdateSuiteName(name string)
}

InterpreterView is the view attached to an interpreter.

type Location added in v0.2.0

type Location struct {
	// ProbeIP is the probe IP address.
	ProbeIP string `json:"probe_ip"`

	// ProbeASN is the probe IP address AS number.
	ProbeASN LocationASNumber `json:"probe_asn"`

	// ProbeCC is the probe IP country code.
	ProbeCC string `json:"probe_cc"`

	// ProbeNetworkName is the probe IP network name.
	ProbeNetworkName string `json:"probe_network_name"`

	// ResolverIP is the IP address used by getaddrinfo.
	ResolverIP string `json:"resolver_ip"`

	// ResolverASN is the resolver IP AS number.
	ResolverASN LocationASNumber `json:"resolver_asn"`

	// ResolverCC is the resolver IP country code.
	ResolverCC string `json:"resolver_cc"`

	// ResolverNetworkName is the resolver IP network name.
	ResolverNetworkName string `json:"resolver_network_name"`
}

Location is the location relative to a given IP address.

func (*Location) SameASNAndCC added in v0.2.0

func (a *Location) SameASNAndCC(b *Location) bool

SameASNAndCC returns whether two locations have the same ASN and CC.

type LocationASNumber added in v0.2.0

type LocationASNumber int64

LocationASNumber is an autonomous system number.

func (LocationASNumber) String added in v0.2.0

func (asn LocationASNumber) String() string

String converts the AS number to the "AS%d" string.

type MiniNettestDescriptor

type MiniNettestDescriptor struct {
	// ID is the unique ID of this mini nettest within the nettest.
	ID string `json:"id"`

	// RunMiniNettest is the mini nettest to run.
	RunMiniNettest string `json:"run_mini_nettest"`

	// WithTarget is the mini nettest target.
	WithTarget json.RawMessage `json:"with_target"`
}

MiniNettestDescriptor is a descriptor for a small nettest that runs embedded inside a OONI nettest.

Jump to

Keyboard shortcuts

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