Add justification for preview features/structured concurrency
This commit is contained in:
parent
896e78679d
commit
7010d80c55
@ -13,6 +13,17 @@ Make sure you're using the correct JVM arguments (`--enable-preview`).
|
||||
Optionally add `-javaagent:opentelemetry-javaagent.jar -Dotel.javaagent.configuration-file=opentelemetry-javaagent.properties`
|
||||
to enable OpenTelemetry tracing.
|
||||
|
||||
### Preview features (`--enable-preview`)
|
||||
Due to wanting to make many concurrent calls to various backend APIs, preview features have been enabled to gain access
|
||||
to [Structured Concurrency (JEP 499)](http://openjdk.java.net/jeps/499).
|
||||
See `src/main/java/se/dsv/studentportalen/bff/TestController.java` for an example of how to use it.
|
||||
To see it in action browse to http://localhost:8080/test and check the tracing data, and you'll see that the overall
|
||||
duration is much lower than if the calls were made sequentially.
|
||||
|
||||
An alternative would be to use [`CompletableFuture`](https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/util/concurrent/CompletableFuture.html)
|
||||
but that would require writing Java in a completely different style with a lot of callbacks instead of the
|
||||
imperative-looking code that Structured Concurrency offers.
|
||||
|
||||
## Mocking backend APIs
|
||||
[Apimposter](https://gitea.dsv.su.se/DMC/apimposter) is used to mock the backend APIs.
|
||||
The mock data is defined in `src/mock-api`. See the linked documentation for details on how to define the mock data.
|
||||
|
Loading…
x
Reference in New Issue
Block a user