Skip to content

peakle/bees

Repository files navigation

Bees

Tests codecov Go Report Card Go Reference

Bees - simple and lightweight worker pool for go.

Benchmarks:

WorkerPool:

WorkerPoolBench

only 37MB used for 500k workers pool

Goroutines:

GoroutinesBench

Semaphore:

SemaphoreBench

Examples:

package main

import (
	"context"
	"fmt"

	"github.com/peakle/bees"
)

// Example - demonstrate pool usage
func Example() {
	pool := bees.Create(context.Background())
	defer pool.Close()

	t := 1
	task := func(ctx context.Context) {
		t++
		fmt.Println(t)
	}
	pool.Submit(task)
	pool.Submit(task)
	pool.Submit(task)

	pool.Wait()
	// Output:
	// 1
	// 2
	// 3
}