limiter

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2016 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Limiters helps to describe different schedulers

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Drain

func Drain(ctx context.Context, l Limiter) (int, error)

Drain counts all ticks from limiter

Types

type Limiter

type Limiter interface {
	Start(context.Context) error
	Control() <-chan struct{}
}

Limiter interface describes limiter control structure

func NewBatch

func NewBatch(batchSize int, master Limiter) (l Limiter)

NewBatch returns batch limiter that makes batch with size batchSize on every master tick master shouldn't be started

func NewCompositeFromConfig

func NewCompositeFromConfig(c *config.Limiter) (l Limiter, err error)

func NewLinear

func NewLinear(startRps, endRps, period float64) (l Limiter)

func NewLinearFromConfig

func NewLinearFromConfig(c *config.Limiter) (l Limiter, err error)

NewLinearFromConfig returns linear limiter

func NewPeriodic

func NewPeriodic(period time.Duration) (l Limiter)

func NewPeriodicFromConfig

func NewPeriodicFromConfig(c *config.Limiter) (l Limiter, err error)

NewPeriodicFromConfig returns periodic limiter

func NewSize

func NewSize(size int, master Limiter) (l Limiter)

NewSize returns size limiter that cuts master limiter by size master shouldn't be started

func NewUnlimitedFromConfig

func NewUnlimitedFromConfig(c *config.Limiter) (l Limiter, err error)

Jump to

Keyboard shortcuts

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