tcprunner

package
v1.68.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 13 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TCPURLPrefix is the URL prefix for triggering TCP load.
	TCPURLPrefix = "tcp://"
	// TCPStatusOK is the map key on success.
	TCPStatusOK = "OK"
)

Functions

func GeneratePayload

func GeneratePayload(t int, i int64) []byte

GeneratePayload generates a default 24 bytes unique payload for each runner thread and message sent when no other payload is set.

Types

type RunnerOptions

type RunnerOptions struct {
	periodic.RunnerOptions
	TCPOptions // Need to call Init() to initialize
}

RunnerOptions includes the base RunnerOptions plus TCP specific options.

type RunnerResults

type RunnerResults struct {
	periodic.RunnerResults
	TCPOptions
	RetCodes      TCPResultMap
	SocketCount   int
	BytesSent     int64
	BytesReceived int64
	// contains filtered or unexported fields
}

RunnerResults is the aggregated result of an TCPRunner. Also is the internal type used per thread/goroutine.

func RunTCPTest

func RunTCPTest(o *RunnerOptions) (*RunnerResults, error)

RunTCPTest runs a TCP test and returns the aggregated stats. Some refactoring to avoid copy-pasta between the now 3 runners would be good.

func (*RunnerResults) Run

func (tcpstate *RunnerResults) Run(_ context.Context, t periodic.ThreadID) (bool, string)

Run tests TCP request fetching. Main call being run at the target QPS. To be set as the Function in RunnerOptions.

type TCPClient

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

TCPClient is the client used for TCP echo testing.

func NewTCPClient

func NewTCPClient(o *TCPOptions) (*TCPClient, error)

NewTCPClient creates and initialize and returns a client based on the TCPOptions.

func (*TCPClient) Close

func (c *TCPClient) Close() int

Close closes the last connection and returns the total number of sockets used for the run.

func (*TCPClient) Fetch

func (c *TCPClient) Fetch() ([]byte, error)

type TCPOptions

type TCPOptions struct {
	Destination      string
	Payload          []byte // what to send (and check)
	UnixDomainSocket string // Path of Unix domain socket to use instead of host:port from URL
	ReqTimeout       time.Duration
}

TCPOptions are options to the TCPClient.

type TCPResultMap

type TCPResultMap map[string]int64

Jump to

Keyboard shortcuts

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