ostelco-core
ostelco-core copied to clipboard
[WIP] Use coroutineScope and async instead of CountDownLatch
Using deferred to wait for all async calls to end instead of using a CountDownLatch.
Do not merge this, I want to test this more to be sure it is working correctly
DO NOT MERGE THIS. The Kotlin Coroutine might not work.
The scope will work when the child coroutines are async using suspend. In that case, the callback is handled as a continuation.
But in this case, the callback is an execution of the lambda function which is passed as the last parameter.
So, the parent coroutine scope will be blocked till all the coroutines in it are completed, but they get completed immediately. The scope will not be blocked until all the callbacks are executed.
Are you talking about the bimap lamda? I don't see any asynchronous calls than the async
in consumeRequestHandler
. If the whole loop (request.msccList.forEach
) runs synchronously, the asyncs methods will be called before the loop is finished. In such cases the async calls are part of the coroutineScope
I have reverted the change I made for converting CompletionStage to Deferred. The load test with 10_000
requests failed with this change. The max I could do was 500
That revert made the creditControlRequestInitTerminateNoCredit
fail. So bringing the change back. We need to sit together and understand this