Lulu
11/17/2020, 3:32 PMFlow
of requests that need to be processed by (many) different workers, and I was wondering which option is better from the following:
1. Have each worker apply filter { }
on the main Flow
to check if this request belongs to it.
2. Have a separate Flow
for each worker, and a general worker that checks all the main `Flow`'s requests and re-emit each request to the corresponding worker's Flow
.
3. (possibly something I haven't thought of?)Dominaezzz
11/17/2020, 3:40 PMLulu
11/17/2020, 3:41 PMShalom Halbert
11/17/2020, 3:57 PMfilter
lambda as a function parameter be suitable?Lulu
11/17/2020, 3:59 PMandylamax
11/17/2020, 5:30 PMLulu
11/17/2020, 7:19 PMfilter { }
then a terminal operation? Is that what you're suggesting each worker do?andylamax
11/17/2020, 7:55 PMfun <T> eventFlow(type: T) : Flow<T> = when(type
) {
is A -> flow<A>{}
is B -> flow<B>{}
// . . . .
}Lulu
11/17/2020, 7:59 PMandylamax
11/17/2020, 8:03 PMLulu
11/17/2020, 8:05 PMwhen { }
to decide which downstream flow it is going to without re-emitting it into that downstream flow? Unless I missed your point.andylamax
11/17/2020, 8:27 PM