typelevel / typelevel/cats-effect

Proposal: IO#raceMany that accepts collection of IO[T], returns winner and cancels others

Open
#512 14 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
2.2k
Forks
576
Avg merge
2d 11h
Merged PRs (30d)
18

Description

I've been considering a race scenario implementation for a collection of IOs. Concept itself is similar to IO#race but stretched out to many IOs. Input is a collection of IO[T]. The return value is a race winner (first completed) wrapped as IO[Either[Throwable, T]] while other IOs are canceled.

I've pushed an example to my repo, just have in mind this is quick and dirty effort of one evening ;) Based on original IO#race code.

https://github.com/Adam-Kurzawa/cats-race-many/blob/master/src/main/scala/cats/effect/internals/IORaceCollection.scala

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked example in src/main/scala/cats/effect/internals/IORaceCollection.scala and compare it with the existing IO#race implementation. Before coding, clarify the collection API, winner representation, and cancellation behavior; done means the project has an agreed raceMany design implemented with matching behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.