AbsaOSS / login-service

AbsaOSS Common Login gateway using JWT Public key signatures
Apache License 2.0
2 stars 0 forks source link

Decide to either execute code concurrently or not #33

Open jakipatryk opened 1 year ago

jakipatryk commented 1 year ago

Background

Currently in controllers we return CompletableFutures, but code is not executed concurrently (Tomcat's connection accepting threads are blocked by our code [authentication and services]). I don't think running services code (JWT generation etc.) is expensive-enough to have it concurrent though.

Feature

Decide whether to remove CompletableFuture (simplifies code), or try to do things concurrently (which is nontrivial as in Spring WebMVC it is impossible to perform authentication in another thread and something like Spring WebFlux would be needed).

I personally would prefer to not go with concurrency approach for this project and just remove CompletableFutures.

dk1844 commented 1 year ago

I don't think running services code (JWT generation etc.) is expensive-enough to have it concurrent though. I agree with that. However, Wrapping with with a (Completable)Future gives you the ability to base your code on services with scala futures more easily, for-comprehend there/map etc - so I actually found it easier to integrate should that need arise.

If we are reasonably sure that we will mostly not need Futures in other layers, we can remove the futures in the controllers, too.