balance

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(cap int) chan<- Request

New returns a receive-only request channel processed by `cap` balanced workers

Types

type Balancer

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

Balancer has a Pool of Workers and a channel for Workers having finished

type Pool

type Pool []*Worker

Pool is a slice of (pointers to) Worker and implements Heap: Len Less Swap Push Pop.

func (*Pool) Len

func (p *Pool) Len() int

Len reports the number of elements in the heap.

func (*Pool) Less

func (p *Pool) Less(i, j int) bool

Less reports whether the element @ [i] should sort before the element @ [j].

func (*Pool) Pop

func (p *Pool) Pop() (v interface{})

Pop removes and returns the element @ [ Len() - 1 ].

func (*Pool) Push

func (p *Pool) Push(v interface{})

Push add v as element @ [ Len() ].

func (*Pool) Swap

func (p *Pool) Swap(i, j int)

Swap swaps the elements @ [i] and [j].

type Request

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

Request is a function to be applied and channel on which to return the result.

type Worker

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

A Worker works on received requests

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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