• Stars
    star
    4
  • Rank 3,304,323 (Top 66 %)
  • Language
    Go
  • License
    MIT License
  • Created about 3 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

High performance, type safe, concurrency limiting worker pool package for golang!

GOWP

PkgGoDev Build and Test Status PkgGoDev

Package gowp (Go Worker-Pool) provides concurrency limiting, error propagation, and Context cancellation for a group of workers/goroutines.

Features

  • Context cancellation, won't process new tasks if parent context gets cancelled.
  • Error propagation, will return the first error encountered.
  • Exit on error, if specified, it won't process further tasks if an error is encountered.
  • Concurrency limiting

Installation

go get -u github.com/akshaybharambe14/gowp

Why?

Goroutines are cheap in terms of memory, but not free. If you want to achieve extreme performance, you need to limit the number of goroutines you use. Also, in real world applications, you need to take care of the failures. This package does that for you.

This package works best with short bursts of tasks. We have other packages that are meant for running huge number of tasks.

Why yet another worker pool implementation

I wanted to build a perfect worker pool implementation with above specified features. We have other implementations, but I think they do a lot of work in background if used to execute fixed set of tasks. Gowp outperforms some of them (see benchmarks).

Benchmarks

For following benchmarks, a single operation means running 10 tasks over 4 workers. Packages compared (results are in same sequence as packages are listed):

  • github.com/akshaybharambe14/gowp
  • github.com/gammazero/workerpool
  • github.com/alitto/pond
$ go test -bench=. -benchmem github.com/akshaybharambe14/gowp/benchmarks
goos: windows
goarch: amd64
pkg: github.com/akshaybharambe14/gowp/benchmarks
cpu: Intel(R) Core(TM) i5-4200M CPU @ 2.50GHz
Benchmark_simple_gowp-4                    79420             13663 ns/op             704 B/op         13 allocs/op
Benchmark_simple_workerpool-4              40402             29716 ns/op             952 B/op         17 allocs/op
Benchmark_simple_pond-4                    57692             20689 ns/op             968 B/op         20 allocs/op
PASS
ok      github.com/akshaybharambe14/gowp/benchmarks     4.323s

Examples

see package examples

Contact

Akshay Bharambe


If this is not something you are looking for, you can check other similar packages on go.libhunt.com.

Do let me know if you have any feedback. Leave a ⭐ if you like this work.

More Repositories

1

gouf

Most commonly used utility/helper functions for generic types in Go.
Go
18
star
2

golang-examples

This repository contains sample golang examples which I come across while learning or trying new things. It also contains tests and benchmarks of various operations.
Go
11
star
3

docgo

Now you are just a click away from official package documentation for Go repositories. DOCGO is a handy browser extension 🧱 to redirect from Go source code repositories to their official documentation 📄.
CSS
11
star
4

go-jsonc

go-jsonc provides a way to work with commented json by converting it to plain json.
Go
10
star
5

ijson

Go package to quickly query and manipulate interface data.
Go
10
star
6

gofl

Generic Free List implementation to reuse memory and avoid allocations
Go
3
star
7

cloud-native-go

Introduction to docker and kubernetes with cloud native Go.
2
star
8

go-workerpool

A worker pool in go.
Go
2
star
9

go-docker

Simple tutorial to containerize and publish your go app to Docker
Dockerfile
2
star
10

vue-js-template-project

A template project for vue js with configured eslint and prettier.
Vue
2
star
11

golang-concurrent-csv

golang-concurrent-csv
1
star
12

spinner

Simple spinner for golang CLI apps.
Go
1
star
13

akshaybharambe14.github.io

Portfolio website
1
star
14

portfolioDev

Portfoio Website
1
star
15

akshaybharambe14

1
star
16

go-unusual

Some functionalities that are unusual/unsafe, but are useful in some edge/exceptional cases.
1
star
17

modulesExample

An example to get started with golang modules
Go
1
star
18

golang-postgresql-example

Go
1
star
19

gohooks

GoHooks make it easy to send and consume secured web-hooks from a Go application
Go
1
star
20

one-click-hugo-cms

CSS
1
star
21

go-generics-tests-bug

Details of a bug in compiling tests files with generic code.
Go
1
star
22

go-rotate

Go
1
star