Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

concurrency.ForEachJob() #113

Merged
merged 9 commits into from
Jan 12, 2022
Merged

concurrency.ForEachJob() #113

merged 9 commits into from
Jan 12, 2022

Commits on Jan 11, 2022

  1. concurrency.ForEachJob() replaces .ForEach()

    Previous `ForEach()` required transforming the input into a slice of
    interfaces (causing an allocation on heap for each job, although that's
    minor here), and type asserting each job in the function later (generics
    will save us, but they're still not here). Plus since job index is not
    known, most use cases require a mutex to concatenate the results.
    
    This replaces it with `ForEachJob` instead, which provides the index of
    the job to `jobFunc` instead, letting it decide how to handle it. In
    most cases that usage will be accessing the original jobs slice, with
    proper type checking. Given the index of the job is known, no mutex is
    needed to store the result in a slice afterwards (see test change), plus
    since indexes are just ints, we don't even need a channel.
    
    This fits all the `concurrency.ForEach` uses I could find, and since
    there's no released version of dskit yet, I just removed that function.
    
    Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
    colega committed Jan 11, 2022
    Configuration menu
    Copy the full SHA
    3f61fb4 View commit details
    Browse the repository at this point in the history
  2. Add BenchmarkForEachJob

    Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
    colega committed Jan 11, 2022
    Configuration menu
    Copy the full SHA
    0f6aeb7 View commit details
    Browse the repository at this point in the history
  3. Update CHANGELOG.md

    Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
    colega committed Jan 11, 2022
    Configuration menu
    Copy the full SHA
    1d3748e View commit details
    Browse the repository at this point in the history
  4. Remove the low-value benchmark

    Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
    colega committed Jan 11, 2022
    Configuration menu
    Copy the full SHA
    5b0be33 View commit details
    Browse the repository at this point in the history
  5. Bring ForEach back, with proper deprecation notice

    Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
    colega committed Jan 11, 2022
    Configuration menu
    Copy the full SHA
    6faae52 View commit details
    Browse the repository at this point in the history
  6. PR feedback on job order and ctx.Err check

    Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
    colega committed Jan 11, 2022
    Configuration menu
    Copy the full SHA
    a491840 View commit details
    Browse the repository at this point in the history

Commits on Jan 12, 2022

  1. Update deprecation comments

    Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
    
    Co-authored-by: Peter Štibraný <peter.stibrany@grafana.com>
    colega and pstibrany authored Jan 12, 2022
    Configuration menu
    Copy the full SHA
    2934349 View commit details
    Browse the repository at this point in the history
  2. Don't define a variable for context.Background()

    Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
    colega committed Jan 12, 2022
    Configuration menu
    Copy the full SHA
    a19cdad View commit details
    Browse the repository at this point in the history
  3. go fmt

    Signed-off-by: Oleg Zaytsev <mail@olegzaytsev.com>
    colega committed Jan 12, 2022
    Configuration menu
    Copy the full SHA
    133a232 View commit details
    Browse the repository at this point in the history