protocol

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package protocol defines the shared interface every wire protocol driver (HTTP/1.1, HTTP/2, gRPC, WebSocket) implements, plus the request and result types they exchange with the engine.

This package, and the driver packages beneath it, are the only places in VegaLoad that know what HTTP, gRPC, or a WebSocket handshake actually look like on the wire. internal/engine calls a driver's Do method through this interface and otherwise knows nothing protocol-specific — see AGENTS.md's module boundaries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Protocol

type Protocol interface {
	// Name identifies the driver, e.g. "http1", "grpc".
	Name() string

	// Do performs one iteration against the configured target. Return
	// a non-nil error only for a failure that should stop the whole
	// run, such as a misconfigured target — a failed individual
	// request is a Result with Success: false and Err set, not a
	// returned error.
	Do(ctx context.Context) (Result, error)

	// Close releases any resources the driver holds (connections,
	// clients). Called once, after every VU using this driver instance
	// has stopped.
	Close() error
}

Protocol is implemented by each wire protocol driver. The engine package calls Do once per iteration and Close once the driver is no longer needed; it holds no protocol-specific knowledge of its own.

type Result

type Result struct {
	// Success is whether this iteration counts as a pass. A driver
	// decides this itself: the HTTP drivers treat 2xx/3xx as success
	// unless configured otherwise.
	Success bool
	// StatusCode is protocol-specific (HTTP status, gRPC status code,
	// ...). Zero if not applicable.
	StatusCode int
	// BytesSent and BytesReceived are best-effort byte counts for the
	// iteration. Zero if a driver doesn't track them.
	BytesSent     int64
	BytesReceived int64
	// Err describes why Success is false. It is informational only —
	// unlike Do's returned error, a non-nil Err does not stop the run.
	Err error
}

Result is what a driver reports after one Do call — enough detail for internal/report (Phase 1) to build percentiles and pass/fail counts without needing to know which protocol produced it.

type Target

type Target struct {
	// URL is the target address: an http(s):// URL for the HTTP
	// drivers, a ws(s):// URL for WebSocket, or a host:port for gRPC.
	URL string
	// Method is the HTTP verb (GET, POST, ...) for the HTTP drivers,
	// defaulting to GET if empty; for the gRPC driver it is instead the
	// full RPC method, e.g. "/package.Service/Method", which has no
	// default and must be set. Ignored by WebSocket.
	Method string
	// Headers are sent as request headers (HTTP) or connection
	// metadata (gRPC), depending on the driver.
	Headers map[string]string
	// Body is the request payload, if any.
	Body []byte
	// InsecureSkipVerify disables TLS certificate verification for
	// drivers that speak TLS. It exists for testing against targets
	// with self-signed or internal-CA certificates; it is false (verify
	// normally) by default and a scenario author has to opt in.
	InsecureSkipVerify bool
}

Target describes what a driver connects to and how, in terms generic enough to cover any of the four wire protocols VegaLoad supports. Each driver interprets the fields relevant to it and ignores the rest — for example Method is meaningless to the WebSocket and gRPC drivers.

Directories

Path Synopsis
Package grpc implements a protocol.Protocol driver for gRPC.
Package grpc implements a protocol.Protocol driver for gRPC.
Package http1 implements a protocol.Protocol driver that speaks plain HTTP/1.1.
Package http1 implements a protocol.Protocol driver that speaks plain HTTP/1.1.
Package http2 implements a protocol.Protocol driver that speaks HTTP/2, over TLS (the normal case, negotiated via ALPN) or over plain TCP ("h2c") when the target is an http:// URL — many internal services run h2c precisely to skip TLS termination, and a load tester that only understood h2-over-TLS would be unable to test them at all.
Package http2 implements a protocol.Protocol driver that speaks HTTP/2, over TLS (the normal case, negotiated via ALPN) or over plain TCP ("h2c") when the target is an http:// URL — many internal services run h2c precisely to skip TLS termination, and a load tester that only understood h2-over-TLS would be unable to test them at all.
Package websocket implements a protocol.Protocol driver for WebSocket.
Package websocket implements a protocol.Protocol driver for WebSocket.

Jump to

Keyboard shortcuts

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