utils

package
v0.35.1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AntsPool added in v0.24.0

func AntsPool(maxInFlight int) (*ants.Pool, error)

func CalculateDelayAccuracy added in v0.29.0

func CalculateDelayAccuracy(payload *[]byte, delayMs int64) (time.Duration, bool)

CalculateDelayAccuracy calculates the accuracy of delayed message delivery. It compares the expected delivery time (timeSent + delay) with the actual delivery time. Returns the delay accuracy (negative means early, positive means late) and whether the message was delayed.

func CalculateEndToEndLatency

func CalculateEndToEndLatency(payload *[]byte) (time.Time, time.Duration)

func ExecuteTemplate added in v0.32.0

func ExecuteTemplate(tmpl *template.Template, id int) string

func FormatTimestamp added in v0.7.0

func FormatTimestamp(timestamp uint64) time.Time

func GetEndpoints added in v0.21.0

func GetEndpoints(serviceName string) ([]string, error)

K8sGet performs a GET request on the Kubernetes API with the given URL; We only need 1 GET on a simple REST endpoint, and this way we avoid importing go-client with lots of dependencies

func InjectId added in v0.13.0

func InjectId(s string, id int) string

func MessageBody

func MessageBody(staticSize int, sizeTemplate *template.Template, id int) []byte

func ParseHeaders added in v0.30.0

func ParseHeaders(headerStrings []string) map[string]any

ParseHeaders parses header strings in the format "key1=value1,key2=value2" and converts numeric values to appropriate types (int64 or float64)

func ParseHeadersWithTemplates added in v0.31.0

func ParseHeadersWithTemplates(headerStrings []string) (map[string]any, map[string]*template.Template, error)

ParseHeadersWithTemplates parses header strings as templates. Non-template strings will return as-is when executed.

func ParseSize added in v0.33.0

func ParseSize(sizeStr string) (int, error)

ParseSize parses a size string that may include units (e.g., "10mb", "1kb", "100") Supported units: b, kb, mb (case-insensitive) If no unit is specified, assumes bytes

func ParseURI added in v0.7.0

func ParseURI(rawURI string, defaultScheme string, defaultPort string) uri

func Rate added in v0.14.0

func Rate(rate float32) string

func RateLimiter added in v0.24.0

func RateLimiter(publishRate float32) *rate.Limiter

func ReorderUrls added in v0.35.0

func ReorderUrls(urls []*url.URL, spreadConnections bool, clientId int) []*url.URL

ReorderUrls reorders URLs based on SpreadConnections setting and client ID.

func ResolveTerminus added in v0.32.0

func ResolveTerminus(destination string, template *template.Template, id int, cfg config.Config) string

func UpdatePayload

func UpdatePayload(useMillis bool, payload *[]byte) *[]byte

func WrappedSequence added in v0.7.1

func WrappedSequence(len int, start int) []int

generate a sequence of `len` integres starting with `start` and wrapped, so that it contains all values from 0 to len-1

Types

This section is empty.

Jump to

Keyboard shortcuts

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