Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: FederatedTypePromiseResolver to settle all promises regardless of errors #1753

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.

None yet

3 participants