fix: workers obey context
This commit is contained in:
12
runner.go
12
runner.go
@@ -51,13 +51,15 @@ type RunConfig struct {
|
||||
Concurrency int
|
||||
}
|
||||
|
||||
// Run starts concurrency threads (goroutines), reads from provided Reader,
|
||||
// executes each Processor in the order they were provide and records result
|
||||
// with provided Writer.
|
||||
// At first Read is called offset times with output of Read being discarded.
|
||||
// Run starts the script described by r.
|
||||
// First Read is called offset times with output of Read being discarded.
|
||||
// Then limit Reads are made and processor is called for each portion
|
||||
// of data. If limit is 0 then Runner keep processing input until it receives
|
||||
// of data. If limit is 0 then Run keep processing input until it receives
|
||||
// EOF from Reader.
|
||||
// Run fails on any error including Reader error, Writer error and Processor error.
|
||||
// If an error is encountered the writer operation will be attampted anyway so that
|
||||
// the output is left in consistent state, recording what has been actually done
|
||||
// by Processor.
|
||||
func Run(ctx context.Context, r RunConfig) error {
|
||||
if r.Concurrency == 0 {
|
||||
r.Concurrency = 1
|
||||
|
Reference in New Issue
Block a user