rainbowdashlabs/sadu

Assistance Needed with Upgrading from SADU v1.4.1

Closed this issue · 3 comments

Hello,

I've been using SADU v1.4.1 for a while now and noticed that there are new updates available. However, I'm a bit confused about the changes. I appreciated the use of CompletableFutures in the previous version, but it seems that this feature has been removed in the newer versions.

Could you please clarify whether it is still beneficial to use CompletableFutures in combination with something like Query#query in the latest version? If not, what is the recommended approach for handling asynchronous operations now?

Thank you for your assistance!

There is also a migration guide. Not sure whether you found it already c:
https://sadu.docs.chojo.dev/queries/migration/

Handling threading wasnt really the scope of sadu to begin with. usually it clutters the code and makes it more complex than required.

Especially with Virtual Threads being a stable feature now in java threading became even more irrelevant. In web applications a request is now handled on a virtual thread which allows you to do everything in a blocking fashion anyway.
The generally preferred way now is to just use virtual threads when you have some kind of web service and just do everything blocking.

I dont know your exact use case tho, so if you require asynchronous code for some other reason just wrap the call to the database into a single CompletableFuture#supplyAsync and call it a day. Thats what sadu did as well previously.

I hope this helps you.

Ahh, thank you for your help. I'm using it in my Minecraft Plugin, and I find CompletableFutures very beneficial.

Yeah in that case you should use those.
Implementing threading wasnt really feasible with the new way queries are defined, thats why I threw away that part to make the general usability better over all.

I personally use my own threading utils for minecraft, which allow easy backsyncing onto the main thread if required.
Its based on some stuff from lucko and proved to be quite usable.
https://github.com/eldoriarpg/eldo-util/blob/main/threading/src/main/java/de/eldoria/eldoutilities/threading/futures/CompletableBukkitFuture.java
https://github.com/eldoriarpg/eldo-util/blob/main/threading/src/main/java/de/eldoria/eldoutilities/threading/futures/BukkitFutureResult.java