Skip to content

Commit

Permalink
feat: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mehditeymorian committed Jun 22, 2022
1 parent 88e264b commit 1706fd3
Showing 1 changed file with 54 additions and 2 deletions.
56 changes: 54 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,54 @@
# koi
Goroutine Pool and Worker Manager
<h1 align="center">
<img alt="Koi logo" src="asset/logo.webp" width="500px"/><br/>
KOI
</h1>
<p align="center">Goroutine and Worker Manager</p>

<p align="center">
<a href="https://pkg.go.dev/github.com/mehditeymorian/koi/v3?tab=doc"target="_blank">
<img src="https://img.shields.io/badge/Go-1.18+-00ADD8?style=for-the-badge&logo=go" alt="go version" />
</a>&nbsp;
<img src="https://img.shields.io/badge/license-apache_2.0-red?style=for-the-badge&logo=none" alt="license" />

<img src="https://img.shields.io/badge/Version-1.0.0-informational?style=for-the-badge&logo=none" alt="version" />
</p>

# 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.AddJob("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.

0 comments on commit 1706fd3

Please sign in to comment.