CLOVIS
02/22/2026, 5:55 PMdata class Task(
val groupId: Uuid,
val payload: …
)
I receive new tasks asynchronously. I want to execute tasks in parallel as fast as possible (= so, a channel with fan-out to many workers) but: two tasks with the same groupId may not execute in parallel. Also, tasks with a given groupId must execute sequentially in the same order as they were created.
If there were only a dozen groups, I would create a channel each, but here there are thousands of groups (if not more). It's actually very rare that two tasks currently in flight have the same group (it will probably only happen once or twice every minute), so creating that many channels just for this sounds expensive.
What's a simple way to represent this?PHondogo
02/22/2026, 6:54 PMCLOVIS
02/22/2026, 7:43 PMMichael Krussel
02/23/2026, 2:15 AMrnett
02/23/2026, 6:05 PM