How to handle file access in a reactive environment
I’m refactoring some blocking code to reactive (using Reactor). I think most of the methods in the java.nio.file.Files
class are blocking.
Is it right if I replace a method like:
public boolean exists() { return Files.exists(path); }
with:
public Mono<Boolean> exists() { return Mono.fromSupplier(() -> Files.exists(path)); }
I think it’s necessary, especially when cheap HDDs are used.
Or does a library exists in Reactor for this kind of file manipulation?