Racing and Unbiased Select Design Patterns
Learn how to implement the Racing and Unbiased Select design patterns.
We'll cover the following...
Racing design pattern
The Racing design pattern runs multiple jobs concurrently, picking the result that returns first as the winner and discarding others as losers.
We can implement Racing in Kotlin using the select()
function on channels.
Let’s imagine we are building a weather application. For redundancy, we fetch the weather from two different sources, Precise Weather and Weather Today. We’ll describe them as two producers that return their name and temperature.
If we ...