-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* implement workers pool * bump ci versions * lint: unused in tests * lint: test warns
- Loading branch information
Showing
11 changed files
with
965 additions
and
19 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
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 |
---|---|---|
|
@@ -68,4 +68,4 @@ issues: | |
exclude-use-default: false | ||
|
||
service: | ||
golangci-lint-version: 1.24.x | ||
golangci-lint-version: 1.31.x |
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
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,8 +1,8 @@ | ||
module github.com/go-pkgz/flow | ||
|
||
go 1.14 | ||
go 1.15 | ||
|
||
require ( | ||
github.com/stretchr/testify v1.3.0 | ||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a | ||
github.com/stretchr/testify v1.6.1 | ||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package pool | ||
|
||
// Option func type | ||
type Option func(p *Workers) | ||
|
||
// ChunkFn functional option defines chunk func distributing records to particular workers. | ||
// The function should return key string identifying the record. | ||
// Record with a given key string guaranteed to be processed by the same worker. | ||
func ChunkFn(chunkFn func(val interface{}) string) Option { | ||
return func(p *Workers) { | ||
p.chunkFn = chunkFn | ||
} | ||
} | ||
|
||
// ResChanSize sets size of response's channel buffer | ||
func ResChanSize(size int) Option { | ||
return func(p *Workers) { | ||
if size >= 0 { | ||
p.resChanSize = size | ||
} | ||
} | ||
} | ||
|
||
// WorkerChanSize sets size of worker channel(s) | ||
func WorkerChanSize(size int) Option { | ||
return func(p *Workers) { | ||
if size >= 0 { | ||
p.workerChanSize = size | ||
} | ||
} | ||
} | ||
|
||
// Batch sets batch size to collect incoming records in a buffer before sending to workers | ||
func Batch(size int) Option { | ||
return func(p *Workers) { | ||
if size >= 1 { | ||
p.batchSize = size | ||
} | ||
} | ||
} | ||
|
||
// ContinueOnError change default early termination on the first error and continue after error | ||
func ContinueOnError(p *Workers) { | ||
p.continueOnError = true | ||
} | ||
|
||
// OnCompletion set function called on completion for each worker id | ||
func OnCompletion(completeFn CompleteFn) Option { | ||
return func(p *Workers) { | ||
p.completeFn = completeFn | ||
} | ||
} |
Oops, something went wrong.