bbaldino
05/14/2020, 3:43 PM/user/{userId}
, how can I make sure requests pertaining to a specific userId
are handled serially, but requests for different `userId`s can be handled in parallel? I don't want to use a single-threaded dispatcher per userId
, I'd like to have a single shared pool that handles all the requests, just enforcing that requests for a given userId
are handled in order. (I think this is more of a general coroutine question with ktor as an example than a ktor-specific question, but let me know if I'm wrong)withContext
?Zach Klippenstein (he/him) [MOD]
05/14/2020, 4:52 PMuserId
, store their channels in a map by the userId
.bbaldino
05/14/2020, 4:53 PMwithContext
because of how neat it is, but my understanding is that the only way to accomplish the serialization per userId is to have a context per user ID, but then also each context would need it's own dispatcher instance (backed by a single-threaded exectuor) to ensure things were handled in seriallyZach Klippenstein (he/him) [MOD]
05/14/2020, 4:54 PMbbaldino
05/14/2020, 4:56 PMZach Klippenstein (he/him) [MOD]
05/14/2020, 4:57 PMbbaldino
05/14/2020, 4:57 PMZach Klippenstein (he/him) [MOD]
05/14/2020, 4:58 PMactor
builder but that’s basically just a Channel
+ a launch
, nothing special really.bbaldino
05/14/2020, 4:59 PMZach Klippenstein (he/him) [MOD]
05/14/2020, 5:02 PMCompletableDeferred
in the message to the actor for the actor to send the response on.bbaldino
05/14/2020, 5:03 PMZach Klippenstein (he/him) [MOD]
05/14/2020, 5:04 PMMutex
and Semaphore
.bbaldino
05/14/2020, 5:05 PMZach Klippenstein (he/him) [MOD]
05/14/2020, 5:07 PMlock
calls, so you actually would preserve order. But I would verify that first.bbaldino
05/14/2020, 5:07 PMursus
05/18/2020, 7:48 AM