Skip to content

Allow restricting concurrency for parallel op's #16

@freakynit

Description

@freakynit

Current implementation spawn as many go-routines as passed collection size (for example as passed to Map) method in parallel package. While this is perfectly okay to do for up to a few thousand go-routines, it could become problematic for larger values. For example, for a mapping operation that makes any networking call, this is almost equivalent to DOSsing the end service.

Suggestion is to allow configuring concurrency for such parallel operations. Default would be equal to runtime.NumCPU(), whereas, if anything <= 0 is specified, it would automatically switch to current default behavior. Anything greater than 0 would override previous behaviors specified.

Sample implementation with above in mind for Map method can be found here (this diff is against current implementation): https://www.diffchecker.com/4pLAUeMh

Let me know if this looks good. I can work on the PR.

Best wishes...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions