reservoir: Index | Files

package reservoir

import ""


Package Files



const (
    StrategyLeak     = 1 // Removes the first (oldest) element in queue and adds the new one
    StrategyOverflow = 2 // The added element will be lost.

type Reservoir Uses

type Reservoir struct {
    MaxConcurrent    int           // How many requests can be running at the same time. Default: 0 (unlimited)
    MinTime          time.Duration // How long to wait after launching a request before launching another one. Default: 0ms
    MaxQueueLength   int
    OverflowStrategy int
    Queue            []job
    // contains filtered or unexported fields

func NewReservoir Uses

func NewReservoir(maxConcurrent int, minTime time.Duration) *Reservoir

Create a new reservoir struct and start working the queue

func (*Reservoir) Add Uses

func (rv *Reservoir) Add(fn interface{}, args ...interface{})

Add a new call to the queue

func (*Reservoir) LimitQueue Uses

func (rv *Reservoir) LimitQueue(maxQueueLength int, overFlowStrategy int)

Set the queue limit and the strategy whats happens if queue is full

func (*Reservoir) Start Uses

func (rv *Reservoir) Start()

Start working on the queue

func (*Reservoir) Stop Uses

func (rv *Reservoir) Stop()

Stop working no the queue

Package reservoir imports 2 packages (graph). Updated 2018-08-18. Refresh now. Tools for package owners.