From 68c6c71a2bd64538ef12c94f3c362f6e8daad97f Mon Sep 17 00:00:00 2001 From: Dmitry Fedotov Date: Sat, 30 Aug 2025 23:57:36 +0300 Subject: [PATCH] fix: workers obey context --- runner.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/runner.go b/runner.go index 40a792a..2609ea2 100644 --- a/runner.go +++ b/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