core

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCompareSpec added in v0.27.2

func BuildCompareSpec(cfg engine.CompareConfig) *restfile.CompareSpec

BuildCompareSpec turns a run-wide compare override into a spec, or returns nil when the override does not name at least two targets.

func CompareBaseIndex

func CompareBaseIndex(rows []engine.CompareRow, want string) int

func CompareBaseline

func CompareBaseline(rows []engine.CompareRow, want string) string

func Emit

func Emit(ctx context.Context, s Sink, e Evt) error

func NormalizeCompareSpec added in v0.49.1

func NormalizeCompareSpec(spec *restfile.CompareSpec) *restfile.CompareSpec

NormalizeCompareSpec keeps an explicitly set but unknown baseline as typed so the run can reject it before any request is sent.

func RunCompare

func RunCompare(ctx context.Context, dep Dep, sink Sink, pl *ComparePlan) error

func RunPlan

func RunPlan(ctx context.Context, dep Dep, sink Sink, pl *WorkflowPlan) error

func RunProfile

func RunProfile(ctx context.Context, dep Dep, sink Sink, pl *ProfilePlan) error

func StepLabel added in v0.48.1

func StepLabel(step restfile.WorkflowStep, branch string, iter, total int) string

Branch and iteration details need to look the same in engine events, reports, and the UI.

Types

type CmpRowDone

type CmpRowDone struct {
	Meta   EvtMeta
	Row    RowMeta
	Result engine.RequestResult
}

type CmpRowStart

type CmpRowStart struct {
	Meta    EvtMeta
	Row     RowMeta
	Doc     *restfile.Document
	Request *restfile.Request
}

type CompareInput added in v0.49.1

type CompareInput struct {
	Doc      *restfile.Document
	Request  *restfile.Request
	Targets  []vars.Target
	Group    string
	Baseline string
	Run      RunMeta
}

CompareInput describes one compare run: the request to repeat, the resolved targets to repeat it against, and which of them is the baseline. Group is set only when the targets vary one environment group.

type ComparePlan

type ComparePlan struct {
	Run      RunMeta
	Doc      *restfile.Document
	Request  *restfile.Request
	Group    string
	Baseline string
	Targets  []vars.Target
}

func PrepareCompare

func PrepareCompare(in CompareInput) (*ComparePlan, error)

type Dep

type Dep interface {
	CollectVariables(
		doc *restfile.Document,
		req *restfile.Request,
		env vars.Environment,
		sc request.RunScope,
	) map[string]string
	EvalRunVars(
		ctx context.Context,
		doc *restfile.Document,
		req *restfile.Request,
		env vars.Environment,
		sc request.RunScope,
		decls []restfile.RunVar,
	) (vars.NameMap[string], error)
	ExecuteWith(
		doc *restfile.Document,
		req *restfile.Request,
		env vars.Environment,
		opt request.ExecOptions,
	) (engine.RequestResult, error)
	EvalCondition(
		ctx context.Context,
		doc *restfile.Document,
		req *restfile.Request,
		env vars.Environment,
		base string,
		spec *restfile.ConditionSpec,
		vv map[string]string,
		locals rts.Locals,
	) (bool, string, error)
	EvalForEachItems(
		ctx context.Context,
		doc *restfile.Document,
		req *restfile.Request,
		env vars.Environment,
		base string,
		spec request.ForEachSpec,
		vv map[string]string,
		locals rts.Locals,
	) ([]rts.Value, error)
	EvalValue(ctx context.Context, in request.EvalInput) (rts.Value, error)
	PosForLine(doc *restfile.Document, req *restfile.Request, line int) rts.Pos
	ValueString(ctx context.Context, pos rts.Pos, v rts.Value) (string, error)
}

type Evt

type Evt interface {
	// contains filtered or unexported methods
}

type EvtMeta

type EvtMeta struct {
	Run RunMeta
	At  time.Time
}

func MetaOf

func MetaOf(e Evt) EvtMeta

func NewMeta

func NewMeta(run RunMeta, at time.Time) EvtMeta

type IterMeta

type IterMeta struct {
	Index       int
	Total       int
	Warmup      bool
	WarmupIndex int
	WarmupTotal int
	RunIndex    int
	RunTotal    int
	Delay       time.Duration
}

type Mode

type Mode uint8
const (
	ModeUnknown Mode = iota
	ModeWorkflow
	ModeForEach
	ModeCompare
	ModeProfile
)

func (Mode) String

func (m Mode) String() string

type NopSink

type NopSink struct{}

func (NopSink) OnEvt

func (NopSink) OnEvt(context.Context, Evt) error

type ProIterDone

type ProIterDone struct {
	Meta   EvtMeta
	Iter   IterMeta
	Result engine.RequestResult
}

type ProIterStart

type ProIterStart struct {
	Meta    EvtMeta
	Iter    IterMeta
	Doc     *restfile.Document
	Request *restfile.Request
}

type ProfileAccumulator added in v1.9.0

type ProfileAccumulator struct {
	// contains filtered or unexported fields
}

ProfileAccumulator builds snapshots from profile events and their timestamps.

func NewProfileAccumulator added in v1.9.0

func NewProfileAccumulator(pl *ProfilePlan) *ProfileAccumulator

func (*ProfileAccumulator) Apply added in v1.9.0

func (a *ProfileAccumulator) Apply(e Evt)

func (*ProfileAccumulator) OnEvt added in v1.9.0

func (a *ProfileAccumulator) OnEvt(_ context.Context, e Evt) error

func (*ProfileAccumulator) Progress added in v1.9.0

func (a *ProfileAccumulator) Progress() ProfileProgress

func (*ProfileAccumulator) Snapshot added in v1.9.0

func (a *ProfileAccumulator) Snapshot() ProfileSnapshot

type ProfileKey added in v1.9.0

type ProfileKey struct {
	Request string
	Method  string
	URL     string
	Env     string
	Delay   time.Duration
}

ProfileKey identifies runs that can be compared: the same request, environment and delay.

func ProfileKeyOf added in v1.9.0

func ProfileKeyOf(ent history.Entry) ProfileKey

ProfileKeyOf returns the key of a stored profile run. ent.ProfileResults must be set.

type ProfilePlan

type ProfilePlan struct {
	Run     RunMeta
	Doc     *restfile.Document
	Request *restfile.Request
	Spec    restfile.ProfileSpec
	Total   int
}

func PrepareProfile

func PrepareProfile(
	doc *restfile.Document,
	req *restfile.Request,
	run RunMeta,
) (*ProfilePlan, error)

func (*ProfilePlan) Key added in v1.9.0

func (pl *ProfilePlan) Key() ProfileKey

type ProfileProgress added in v1.9.0

type ProfileProgress struct {
	Status       ProfileStatus
	Total        int
	Done         int
	Warmup       int
	WarmupDone   int
	WarmupFailed int
	Count        int
	Measured     int
	Passed       int
	Failed       int
	Elapsed      time.Duration
}

type ProfileSnapshot added in v1.9.0

type ProfileSnapshot struct {
	Progress ProfileProgress
	Delay    time.Duration
	Started  time.Time
	Ended    time.Time
	// Window is the time from the start of the first measured request to the end of the last.
	Window time.Duration
	// Active is the total time spent inside measured requests.
	Active time.Duration
	Stats  analysis.LatencyStats
	// StatusCodes counts measured requests by HTTP status. Code 0 means no response.
	StatusCodes map[int]int
	Failures    []engine.ProfileFailure
	SkipReason  string
	Err         error
	// Legacy identifies history records saved before failure details were kept.
	Legacy bool
}

func ProfileBaseline added in v1.9.0

func ProfileBaseline(entries []history.Entry, k ProfileKey, before time.Time) (ProfileSnapshot, bool)

ProfileBaseline returns the newest finished run for k with latency data that was recorded before the given time.

func ProfileSnapshotFromHistory added in v1.9.0

func ProfileSnapshotFromHistory(ent history.Entry) ProfileSnapshot

ProfileSnapshotFromHistory restores a completed profile run. For older records, it derives the status from the counts and sets Legacy.

func (ProfileSnapshot) ActiveRate added in v1.9.0

func (s ProfileSnapshot) ActiveRate() float64

func (ProfileSnapshot) HistoryEntry added in v1.9.0

func (s ProfileSnapshot) HistoryEntry(
	req *restfile.Request,
	env vars.Environment,
	path string,
	redact func(text string, mask bool) string,
) history.Entry

HistoryEntry builds a record without samples or response bodies. The redact function removes secrets and, when mask is true, sensitive headers.

func (ProfileSnapshot) Summary added in v1.9.0

func (s ProfileSnapshot) Summary() string

func (ProfileSnapshot) WallRate added in v1.9.0

func (s ProfileSnapshot) WallRate() float64

type ProfileStatus added in v1.9.0

type ProfileStatus uint8
const (
	ProfileRunning ProfileStatus = iota
	ProfilePass
	ProfileFail
	ProfileCanceled
	ProfileSkipped
	ProfileError
)

func ParseProfileStatus added in v1.9.0

func ParseProfileStatus(name string) (ProfileStatus, bool)

func (ProfileStatus) String added in v1.9.0

func (s ProfileStatus) String() string

type ReqDone

type ReqDone struct {
	Meta   EvtMeta
	Req    ReqMeta
	Result engine.RequestResult
}

type ReqMeta

type ReqMeta struct {
	Index int
	Label string
	Env   string
}

type ReqStart

type ReqStart struct {
	Meta    EvtMeta
	Req     ReqMeta
	Doc     *restfile.Document
	Request *restfile.Request
}

type RowMeta

type RowMeta struct {
	Index   int
	Env     string
	Profile string
	Base    bool
	Total   int
}

type RunDone

type RunDone struct {
	Meta     EvtMeta
	Success  bool
	Skipped  bool
	Canceled bool
	Err      error
}

type RunMeta

type RunMeta struct {
	ID   string
	Mode Mode
	Name string
	Env  vars.Environment
}

type RunStart

type RunStart struct {
	Meta EvtMeta
}

type Sink

type Sink interface {
	OnEvt(context.Context, Evt) error
}
var Discard Sink = NopSink{}

type SinkFunc

type SinkFunc func(context.Context, Evt) error

func (SinkFunc) OnEvt

func (fn SinkFunc) OnEvt(ctx context.Context, e Evt) error

type StepMeta

type StepMeta struct {
	Index  int
	Name   string
	Kind   restfile.WorkflowStepKind
	Target string
	Branch string
	Iter   int
	Total  int
}

type WfStepDone

type WfStepDone struct {
	Meta   EvtMeta
	Step   StepMeta
	Result engine.RequestResult
}

type WfStepStart

type WfStepStart struct {
	Meta    EvtMeta
	Step    StepMeta
	Doc     *restfile.Document
	Request *restfile.Request
}

type WorkflowPlan

type WorkflowPlan struct {
	Run      RunMeta
	Doc      *restfile.Document
	Workflow restfile.Workflow
	Steps    []WorkflowStepRuntime
	Reqs     map[string]*restfile.Request
	Vars     map[string]string
	WfVars   bool
}

func PrepareForEach

func PrepareForEach(
	doc *restfile.Document,
	req *restfile.Request,
	run RunMeta,
) (*WorkflowPlan, error)

func PrepareWorkflow

func PrepareWorkflow(
	doc *restfile.Document,
	wf restfile.Workflow,
	run RunMeta,
) (*WorkflowPlan, error)

type WorkflowStepRuntime

type WorkflowStepRuntime struct {
	Step restfile.WorkflowStep
	Req  *restfile.Request
}

Jump to

Keyboard shortcuts

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