Skip to content

Worker pool that ramps us the workers and then ramps down

License

Notifications You must be signed in to change notification settings

abkhan/workeramp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

workeramp

Worker pool that ramps us the workers and then ramps down

Theory

The worker pool runs the callback that is provided to it. It checks the return of the callback. If the callback returns > 0, it adds a worker.

This usually works with a Channel where the callback-func returns the lenth of the channel. If the channel has more work, the return value would increase the workers - rampup. If the channel has no more work, the worker thread/goroutine would go away - for rampdown.

Use

// .. echan := make(chan int, 9) //.. ws := NewWorkerSet("Events", 6, 1000, work) //..

func work() (int, error) { select { case a := <-echan: do_something() case <-time.After(5 * time.Second): } return len(echan), nil }

About

Worker pool that ramps us the workers and then ramps down

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages