-
Notifications
You must be signed in to change notification settings - Fork 274
Description
Describe the problem
The majority of the Library API returns futures, even for basic information about the library. This makes it cumbersome to consume libraries, as the caller need to unwrap the future by "blocking" and handling various failure modes that don't actually exist. Meanwhile, for many of these methods, all implementations simply return CompletableFuture.completedFuture(...) as this is plain data associated with the library.
The improvement you'd like to see
Any static metadata (name, namespace, version, etc.) is directly accessible without requiring futures. I.e., instead of:
public interface Library {
CompletableFuture<String> getVersion();
CompletableFuture<String> getNamespace();
CompletableFuture<String> getName();
// etc.
}we would have:
public interface Library {
String getVersion();
String getNamespace();
String getName();
// etc.
}In general, if all of a method's implementations return CompletableFuture.completedFuture(...), it probably doesn't need to return a future at all. Other methods, such as Library#read(URL) can remain future-returning.
Expected Benefits
It will be easier to write, read, and maintain code that consumes libraries. It also won't appear as though we have UI-blocking code when that's not the reality.
Additional Context
No response