Help us shape the future of Go! Take the 2026 Go Developer Survey

providerbenchmark

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SampleBytes          int64 = 32 << 20
	MinimumSampleBytes   int64 = 8 << 20
	MeasurementWindow          = 30 * time.Second
	SessionCreateTimeout       = 15 * time.Second
)

Variables

This section is empty.

Functions

func CurrentServiceURL

func CurrentServiceURL(ctx context.Context, service *observability.Service, providerID types.OnChainID) (string, bool, error)

func Due

func Due(row *Result, currentHash string, retestInterval time.Duration, now time.Time) bool

Due reports whether a provider can start another automatic measurement.

func Eligibility

Eligibility uses the same provider evidence for admission and action views.

func MeasuredFailure

func MeasuredFailure(code string) bool

MeasuredFailure treats unknown failures as completed measurements.

func NonMeasuredFailureCodes

func NonMeasuredFailureCodes() []string

NonMeasuredFailureCodes identifies failures eligible for automatic remeasurement.

func Priority

func Priority(endorsed, approved, bound bool) int

Priority orders measurements by provider membership and accepted bindings.

func URLHash

func URLHash(value string) string

Types

type Checkpoint

type Checkpoint struct {
	Attempted      bool  `json:"attempted"`
	SampleBytes    int64 `json:"sample_bytes,omitempty"`
	DurationMS     int64 `json:"duration_ms,omitempty"`
	BytesPerSecond int64 `json:"bytes_per_second,omitempty"`
}

type Input

type Input struct {
	ProviderID     string `json:"provider_id"`
	ServiceURLHash string `json:"service_url_hash"`
}

type Measurement

type Measurement struct {
	Bytes    int64
	Duration time.Duration
}

type Result

type Result struct {
	bun.BaseModel `bun:"table:provider_upload_speed_tests"`

	ProviderID     string     `bun:"provider_id,pk,type:text" json:"-"`
	State          State      `bun:"state,type:text,notnull" json:"state"`
	ServiceURLHash string     `bun:"service_url_hash,type:text,notnull" json:"-"`
	SampleBytes    int64      `bun:"sample_bytes,notnull" json:"sample_bytes"`
	DurationMS     *int64     `bun:"duration_ms" json:"duration_ms,omitempty"`
	BytesPerSecond *int64     `bun:"bytes_per_second" json:"bytes_per_second,omitempty"`
	TestedAt       *time.Time `bun:"tested_at" json:"tested_at,omitempty"`
	FailureCode    *string    `bun:"failure_code,type:text" json:"failure_code,omitempty"`
	ActiveTaskID   *int64     `bun:"active_task_id" json:"-"`
	CreatedAt      time.Time  `bun:"created_at,notnull" json:"-"`
	UpdatedAt      time.Time  `bun:"updated_at,notnull" json:"-"`
}

func (Result) Outcome

func (r Result) Outcome(serviceURL string) (bytesPerSecond int64, settled bool)

Outcome reads the last settled result, including while a new test is running.

type State

type State string
const (
	StateTesting   State = "testing"
	StateSucceeded State = "succeeded"
	StateFailed    State = "failed"
)

type SuccessfulMeasurement

type SuccessfulMeasurement struct {
	SampleBytes    int64     `json:"sample_bytes"`
	DurationMS     int64     `json:"duration_ms"`
	BytesPerSecond int64     `json:"bytes_per_second"`
	TestedAt       time.Time `json:"tested_at"`
}

SuccessfulMeasurement is a historical reference, independent of current admission.

type UploadProbe

type UploadProbe interface {
	Probe(context.Context, string) (Measurement, error)
}

UploadProbe measures one upload sample against a provider service URL.

Jump to

Keyboard shortcuts

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