delay

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2019 License: MIT Imports: 3 Imported by: 57 modules, 128 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-ipfs-delay

standard-readme compliant GoDoc Build Status

go-ipfs-delay makes it easy to add (threadsafe) configurable delays to other objects.

Table of Contents

Install

go-ipfs-delay works like a regular Go module:

> go get github.com/ipfs/go-ipfs-delay

Usage

import "github.com/ipfs/go-ipfs-delay"

Check the GoDoc documentation

Contribute

PRs accepted.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © Protocol Labs, Inc.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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

func Delay(t time.Duration, generator Generator) D

Delay generates a generic delay form a t, a sleeper, and a generator

func Fixed

func Fixed(t time.Duration) D

Fixed returns a delay with fixed latency

func VariableNormal

func VariableNormal(t, std time.Duration, rng *rand.Rand) D

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

func VariableUniform(t, d time.Duration, rng *rand.Rand) D

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

type Generator interface {
	NextWaitTime(time.Duration) time.Duration
}

Generator provides an interface for generating wait times

func FixedGenerator

func FixedGenerator() Generator

FixedGenerator returns a delay with fixed latency

func VariableNormalGenerator

func VariableNormalGenerator(std time.Duration, rng *rand.Rand) Generator

VariableNormalGenerator makes delays that following a normal distribution

func VariableUniformGenerator

func VariableUniformGenerator(d time.Duration, rng *rand.Rand) Generator

VariableUniformGenerator generates delays following a uniform distribution

Jump to

Keyboard shortcuts

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