Skip to content

Conversation

@samuelAndalon
Copy link
Contributor

@samuelAndalon samuelAndalon commented Apr 17, 2023

📝 Description

the FederatedTypePromiseResolver was originally created with the DataLoader use case in mind, meaning that all returned CompletableFutures are resolved synchronously, to let DataLoader dispatch mechanism to decide when to dispatch, so realistically, when using DataLoaders, there is not an scenario where a particular CompletableFuture might complete exceptionally.

However, nothing stops users to use the FederatedTypePromiseResolver without dataloaders, which means that now CompletableFutures might complete exceptionally in a asynchronous way.

To solve that, create allSettled extension function

fun List<CompletableFuture<out T>>.allSettled(): CompletableFuture<List<Result<T>>>

which will complete all promises even if one or more complete exceptionally. The type of each element in the returned list will be a kotlin Result that encapsulates a successful outcome with a value of type T or a failure with the exception.

🔗 Related Issues

#1747

@samuelAndalon samuelAndalon added the changes: minor Changes require a minor version label Apr 17, 2023
@samuelAndalon samuelAndalon merged commit 9c5ac9a into ExpediaGroup:master Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changes: minor Changes require a minor version

Development

Successfully merging this pull request may close these issues.

3 participants