common

package
v1.15.3 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BodyTypeJSON = "application/json"
	BodyTypeForm = "application/x-www-form-urlencoded"
	BodyTypeText = "text/plain"
)

Variables

View Source
var CommandPrefix = "sponge perftest"

Functions

func CheckBodyParam

func CheckBodyParam(bodyJSON string, bodyFile string) (string, error)

CheckBodyParam checks if the body parameter is provided in JSON or file format.

func CheckPortInUse added in v1.15.3

func CheckPortInUse(port string) string

CheckPortInUse checks if the given port is in use, if not, it returns a new available port.

func NewID

func NewID() int64

NewID generates a new ID for each request.

func NewStringID added in v1.15.3

func NewStringID() string

NewStringID Generate a string ID, the hexadecimal form of NewID(), total 16 bytes.

func ParseHTTPParams

func ParseHTTPParams(method string, headers []string, body string, bodyFile string) ([]byte, map[string]string, error)

nolint

func SetCommandPrefix added in v1.15.3

func SetCommandPrefix(name string)

SetCommandPrefix sets the command prefix for the perftest command.

Types

type Bar

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

Bar represents a thread-safe progress bar.

func NewBar

func NewBar(total int64, t time.Time) *Bar

NewBar returns a new progress bar with the given total count.

func (*Bar) Finish

func (b *Bar) Finish()

Finish marks the bar as complete and prints the final state.

func (*Bar) Increment

func (b *Bar) Increment()

Increment advances the progress by 1 and redraws the bar if needed.

func (*Bar) Stop added in v1.15.3

func (b *Bar) Stop()

Stop halts the bar at its current progress and prints the final state.

type TimeBar

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

TimeBar represents a thread-safe time-based progress bar.

func NewTimeBar

func NewTimeBar(totalDuration time.Duration) *TimeBar

NewTimeBar returns a new time-based progress bar with the given duration.

func (*TimeBar) Finish

func (b *TimeBar) Finish()

Finish stops the progress bar at 100%.

func (*TimeBar) Start

func (b *TimeBar) Start()

Start begins automatic updates in a background goroutine.

func (*TimeBar) Stop added in v1.15.3

func (b *TimeBar) Stop()

Stop halts the progress bar at its current progress.

Jump to

Keyboard shortcuts

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