runtime

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package runtime contains the small shared boundary implemented by protocol modules.

Index

Constants

View Source
const MaxExchanges = 1024
View Source
const MaxResponseBytes int64 = 32 << 20

Variables

This section is empty.

Functions

func AddIssue

func AddIssue(observation *testspec.Observation, stage string, code string)

func ErrorCode

func ErrorCode(ctx context.Context) string

func Exchange

func Exchange(step string, request Request, response Response) testspec.Exchange

func Milliseconds

func Milliseconds(started time.Time) float64

func NewObservation

func NewObservation(protocol string) testspec.Observation

func ObserveCacheWriteHeaders

func ObserveCacheWriteHeaders(response *http.Response, observation *testspec.Observation)

ObserveCacheWriteHeaders keeps only the two public numeric usage counters. Missing headers stay missing; a later workflow step cannot inherit a value.

func Read

func Read(response Response) ([]byte, error)

Types

type AssetMetadata

type AssetMetadata struct {
	SHA256    string
	Size      int64
	MediaType string
}

type AssetResolver

type AssetResolver interface {
	Open(context.Context, string) (AssetStream, error)
}

type AssetStream

type AssetStream interface {
	io.ReadCloser
	Metadata() AssetMetadata
}

AssetStream owns one opened asset. Close must be safe concurrently with Read and unblock a blocked Read so cancellation can release every opened stream.

type Descriptor

type Descriptor struct {
	ID          string                    `json:"id"`
	Label       string                    `json:"label"`
	DefaultSpec testspec.Spec             `json:"default_spec"`
	Metrics     []testspec.Metric         `json:"metrics"`
	Settings    map[string]testspec.Input `json:"settings"`
}

type Execution

type Execution struct {
	Spec      testspec.Spec
	Inputs    testspec.ResolvedInputs
	Random    testspec.RandomContext
	Settings  testspec.RunSettings
	Transport Transport
	Assets    AssetResolver
}

type Module

type Module interface {
	Descriptor() Descriptor
	// ValidateProtocol checks native operation and workflow rules after Spec.Validate.
	ValidateProtocol(testspec.Spec) error
	Execute(context.Context, Execution) testspec.Observation
}

type PreparedFile

type PreparedFile struct {
	InputName string
	Pointer   string
	AssetRef  string
	SHA256    string
	Size      int64
	MediaType string
	Encoding  string
}

type PreparedWire

type PreparedWire struct {
	SHA256 string
	Bytes  int64
	Files  []PreparedFile
}

PreparedWire describes bytes prepared by the transport, never a template or the redacted request view retained in a persisted Exchange.

func (PreparedWire) Clone

func (wire PreparedWire) Clone() PreparedWire

type Request

type Request struct {
	Method  string
	Path    string
	Body    testspec.RenderedRequest
	Headers map[string]string
	Assets  AssetResolver
}

type Response

type Response struct {
	HTTP         *http.Response
	Started      time.Time
	TTFBMS       float64
	RequestBody  json.RawMessage
	PreparedWire *PreparedWire `json:"-"`
}

type TaskProtocol

type TaskProtocol struct {
	ID               string
	Label            string
	SubmitPath       string
	PollPath         string
	IDPointer        string
	StatusPointer    string
	UsagePointer     string
	ArtifactPointers map[string]string
	TerminalStatuses []string
	DefaultBody      json.RawMessage
	Headers          map[string]string
}

TaskProtocol describes a supported external protocol's lifecycle. It contains no expected test outcomes; terminal failure is as observable as terminal success.

func (TaskProtocol) Descriptor

func (protocol TaskProtocol) Descriptor() Descriptor

func (TaskProtocol) Execute

func (protocol TaskProtocol) Execute(ctx context.Context, execution Execution) testspec.Observation

func (TaskProtocol) ValidateProtocol

func (protocol TaskProtocol) ValidateProtocol(spec testspec.Spec) error

type Transport

type Transport interface {
	Send(context.Context, Request) (Response, error)
}

Jump to

Keyboard shortcuts

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