https://github.com/mehditeymorian/koi
Goroutine and Worker Manager
https://github.com/mehditeymorian/koi
concurrency golang goroutine goroutine-pool goroutinemanager pool-manager synchronization
Last synced: 11 months ago
JSON representation
Goroutine and Worker Manager
- Host: GitHub
- URL: https://github.com/mehditeymorian/koi
- Owner: mehditeymorian
- License: apache-2.0
- Created: 2022-06-21T05:11:06.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-10-15T08:57:13.000Z (over 3 years ago)
- Last Synced: 2025-04-09T02:21:43.599Z (about 1 year ago)
- Topics: concurrency, golang, goroutine, goroutine-pool, goroutinemanager, pool-manager, synchronization
- Language: Go
- Homepage:
- Size: 67.4 KB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

KOI
Goroutine and Worker Manager
# Installation
```bash
go get github.com/mehditeymorian/koi
```
# Usage
```Go
// create a pond
pond := koi.NewPond()
// create a worker
worker := koi.Worker{
ConcurrentCount: CONCURRENT_RUNNING_GOROUTINE_FOR_THIS_WORKER,
QueueSize: REQUEST_QUEUE_SIZE,
Work: func(a any) any {
// do some work
return RESULT
},
}
// register worker to a unique id
err = pond.RegisterWorker("workerID", worker)
// add job to worker
// this is non-blocking unless the queue is full.
resultChan, err := pond.AddWork("workerID", requestData)
// read results from worker
for res := range resultChan {
// do something with result
}
```
**Note**: `pond.AddJob` is non-blocking unless worker queue is full.
# Terminology
- **Koi**: Koi is an informal name for the colored variants of C. rubrofuscus kept for ornamental purposes.
- **Pond**: an area of water smaller than a lake, often artificially made.
# Generic Version of KOI
- [Generic KOI](https://github.com/1995parham/koi) written by [Parham](https://github.com/1995parham)