jitter

package module
v0.0.0-...-d77fd50 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2019 License: MIT Imports: 3 Imported by: 1

README

jitter GoDoc

Go tickers with jitter

Installation

go get -u github.com/DMarby/jitter

License

See LICENSE

Documentation

Overview

Example
package main

import (
	"fmt"
	"time"

	"github.com/DMarby/jitter"
)

func main() {
	t := jitter.NewTicker(
		time.Second,
		time.Second*10,
	)

	for tick := range t.C {
		fmt.Println("Tick at", tick)
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ticker

type Ticker struct {
	C <-chan time.Time // Channel which the events are delivered on
	// contains filtered or unexported fields
}

Ticker is a ticker that emits events on a channel at the given interval, with an added delay up to the defined max jitter If the receiever doesn't keep up the events will be discarded

func NewTicker

func NewTicker(interval time.Duration, jitter time.Duration) *Ticker

NewTicker returns a new ticker with the given interval and jitter

func (Ticker) Stop

func (t Ticker) Stop()

Stop will stop the ticker. It does not close the channel.

Jump to

Keyboard shortcuts

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