-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from khunafin/add_interface
extract Pool interface
- Loading branch information
Showing
3 changed files
with
29 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,19 @@ | ||
// Package gop contains golang worker pool helpers. | ||
package gop | ||
|
||
import "context" | ||
|
||
// TaskFn is a wrapper for task function. | ||
type TaskFn func() | ||
|
||
type Pool interface { | ||
// Add adds tasks to the pool. | ||
Add(TaskFn) error | ||
AddContext(context.Context, TaskFn) error | ||
// QueueSize is a current queue size. | ||
QueueSize() int32 | ||
// Shutdown closes pool and stops workers. | ||
// | ||
// If any tasks in a queue left, pool will not take them, so the tasks will be lost. | ||
Shutdown() error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters