package delay
import "github.com/ipfs/go-ipfs-delay"
Index ¶
- type D
- func Delay(t time.Duration, generator Generator) D
- func Fixed(t time.Duration) D
- func VariableNormal(t, std time.Duration, rng *rand.Rand) D
- func VariableUniform(t, d time.Duration, rng *rand.Rand) D
- type Generator
Types ¶
type D ¶
type D interface { Set(time.Duration) time.Duration Wait() NextWaitTime() time.Duration Get() time.Duration }
D (Delay) makes it easy to add (threadsafe) configurable delays to other objects.
func Delay ¶
Delay generates a generic delay form a t, a sleeper, and a generator
func Fixed ¶
Fixed returns a delay with fixed latency
func VariableNormal ¶
VariableNormal is a delay following a normal distribution Notice that to implement the D interface Set can only change the mean delay the standard deviation is set only at initialization
func VariableUniform ¶
VariableUniform is a delay following a uniform distribution Notice that to implement the D interface Set can only change the minimum delay the delta is set only at initialization
type Generator ¶
Generator provides an interface for generating wait times
func FixedGenerator ¶
func FixedGenerator() Generator
FixedGenerator returns a delay with fixed latency
func VariableNormalGenerator ¶
VariableNormalGenerator makes delays that following a normal distribution
func VariableUniformGenerator ¶
VariableUniformGenerator generates delays following a uniform distribution
Source Files ¶
- Version
- v0.0.1 (latest)
- Published
- Feb 28, 2019
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 2 months ago –
Tools for package owners.