go-saturate: github.com/dustin/go-saturate Index | Files

package saturate

import "github.com/dustin/go-saturate"

Package saturate is a tool for keeping pipelines busy.

Index

Package Files

saturate.go

Variables

var DefaultConfig = Config{
    DestConcurrency:  2,
    TotalConcurrency: 4,
    Retries:          3,
}

DefaultConfig for Saturators.

type Config Uses

type Config struct {
    // Number of concurrent workers per destination.
    DestConcurrency int
    // Total number of concurrent in-flight items.
    TotalConcurrency int
    // Number of times to retry a failed task.
    Retries int
}

Config for the worker.

type Saturator Uses

type Saturator struct {
    // contains filtered or unexported fields
}

A Saturator performs a double-fanout of work to keep resource utilization maximized.

func New Uses

func New(dests []string, w func(dest string) Worker,
    conf *Config) *Saturator

New builds a new saturator.

func (*Saturator) Saturate Uses

func (s *Saturator) Saturate(input <-chan WorkInput) error

Saturate distributes all the tasks specified by the input.

Return error if any input task fails execution on all retries.

type WorkInput Uses

type WorkInput struct {
    // The work item the worker should receive.
    Input interface{}
    // The list of eligible worker names (destinations).
    Dests []string
}

WorkInput is the input to the worker.

type Worker Uses

type Worker interface {
    Work(interface{}) error
}

A Worker performs a single item of work.

type WorkerFunc Uses

type WorkerFunc func(interface{}) error

WorkerFunc is a convenience type to make a worker from a function.

func (WorkerFunc) Work Uses

func (w WorkerFunc) Work(i interface{}) error

Work satisfies the Worker interface for a WorkerFunc

Package saturate imports 2 packages (graph) and is imported by 4 packages. Updated 2017-10-25. Refresh now. Tools for package owners.