delay

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Descriptor

type Descriptor struct {
	Name    string
	Summary string
	Args    string
}

Descriptor is one distribution as documentation and completions see it.

func Distributions

func Distributions() []Descriptor

Distributions describes the call forms, in documentation order.

func (Descriptor) Usage

func (d Descriptor) Usage() string

Usage is the example call, e.g. random(100ms,500ms).

type Spec

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

Spec is one parsed delay expression; the zero value never delays. What base and spread hold depends on the kind: the constant delay, the bounds of random, or a center and the deviation around it. A deviation written as a percentage is marked relative so the text round-trips.

func Fixed

func Fixed(d time.Duration) Spec

func Parse

func Parse(raw string) (Spec, error)

Parse reads a duration such as "150ms" or a call such as "random(100ms,500ms)".

func (Spec) IsZero

func (s Spec) IsZero() bool

func (Spec) MarshalText

func (s Spec) MarshalText() ([]byte, error)

The mock reload digest hashes parsed specs as JSON, so a spec has to encode as the text it was written with.

func (Spec) Sample

func (s Spec) Sample() time.Duration

Sample returns the delay for one request. It is never negative and is safe for concurrent use.

func (Spec) String

func (s Spec) String() string

String is the canonical expression, empty when there is no delay.

func (*Spec) UnmarshalText

func (s *Spec) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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