This allows overlapping instances of a given job. To make this easier to
test, this also refactors `StartJob` into a helper `startFunc` to make
this functionality easier to unit test.
Co-authored-by: Pavel Popov <pavelpopov@outlook.com>
Using a (cancellable) context is a little more idiomatic than
re-implementing one using a channel, and it's a little more efficient
(since we share one context across all job goroutines, as opposed to
requiring one cancel channel per goroutine).
`bufio.Scanner` can only handle lines up to 64kB. Beyond that, it'll
crash with `bufio.Scanner: token too long`.
We shouldn't crash when this happens. Instead, let's just continue
reading, and warn the user. This is what this does.
We're launching everything one iteration later than scheduled. That's
not great!
I'd like to rethink the test approach a little bit here. Testing through
the logger is not ideal (we should probably just pump all the logs
through channels back to the main goroutine).