How can i incorporate preprocessing into a service class, will adding them as regular method calls have drastic effects? #1289
-
I am making an API service where the resource, service and repository classes each return Unis/Multis. In the service class i want to preprocess the API request data and then continue and then call the repository which will make a DB call. (i'm loosely following this guide: https://quarkus.io/guides/reactive-sql-clients). From what i understand I can either add the preprocessing method as a regular method call before calling the Repository like so:
Or I could add it in the mutiny chain like so:
I just wanted to understand if there are any performance differences between the two approaches. Also, is there a better way to approach this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Your mileage varies but both are very sound approaches 😉 Assuming For most workloads you shouldn't see any throughput / latency difference, really. |
Beta Was this translation helpful? Give feedback.
Your mileage varies but both are very sound approaches 😉
Assuming
somePreprocessing
isn't doing any I/O work then I'd go with the first variant as it results in a simpler pipeline.That being said the second variant is totally fine, it just allocates a few more objects with the initial
Uni
object creation andtransformToUni
step.For most workloads you shouldn't see any throughput / latency difference, really.