• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

pacer/H06-Apr-2019-

.gitignoreH A D06-Apr-2019270

.travis.ymlH A D06-Apr-2019189

LICENSEH A D06-Apr-20191.1 KiB

README.mdH A D06-Apr-20191.5 KiB

doc.goH A D06-Apr-20193 KiB

go.test.shH A D06-Apr-2019271

workerpool.goH A D06-Apr-20198 KiB

workerpool_test.goH A D06-Apr-20199.9 KiB

README.md

1# workerpool
2[![Build Status](https://travis-ci.org/gammazero/workerpool.svg)](https://travis-ci.org/gammazero/workerpool)
3[![Go Report Card](https://goreportcard.com/badge/github.com/gammazero/workerpool)](https://goreportcard.com/report/github.com/gammazero/workerpool)
4[![codecov](https://codecov.io/gh/gammazero/workerpool/branch/master/graph/badge.svg)](https://codecov.io/gh/gammazero/workerpool)
5[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/gammazero/workerpool/blob/master/LICENSE)
6
7Concurrency limiting goroutine pool. Limits the concurrency of task execution, not the number of tasks queued. Never blocks submitting tasks, no matter how many tasks are queued.
8
9[![GoDoc](https://godoc.org/github.com/gammazero/workerpool?status.svg)](https://godoc.org/github.com/gammazero/workerpool)
10
11This implementation builds on ideas from the following:
12
13- http://marcio.io/2015/07/handling-1-million-requests-per-minute-with-golang
14- http://nesv.github.io/golang/2014/02/25/worker-queues-in-go.html
15
16## Installation
17To install this package, you need to setup your Go workspace.  The simplest way to install the library is to run:
18```
19$ go get github.com/gammazero/workerpool
20```
21
22## Example
23```go
24package main
25
26import (
27	"fmt"
28	"github.com/gammazero/workerpool"
29)
30
31func main() {
32	wp := workerpool.New(2)
33	requests := []string{"alpha", "beta", "gamma", "delta", "epsilon"}
34
35	for _, r := range requests {
36		r := r
37		wp.Submit(func() {
38			fmt.Println("Handling request:", r)
39		})
40	}
41
42	wp.StopWait()
43}
44```
45