Skip to content

Add support for async requests#328

Merged
jimmyjames merged 3 commits intomasterfrom
add-async-support
Feb 4, 2021
Merged

Add support for async requests#328
jimmyjames merged 3 commits intomasterfrom
add-async-support

Conversation

@jimmyjames
Copy link
Copy Markdown
Contributor

Changes

Fixes #315

This change adds the ability to execute a request asynchronously, through the addition of a new default method on the Request interface:

default CompletableFuture<T> executeAsync()

The default interface implementation throws an UnsupportedOperationException. The implementation in BaseRequest returns a CompletableFuture. An example usage:

api.users().list(null).executeAsync().whenComplete((usersPage, ex) -> {
    if (ex != null) {
        System.out.println("Exception occurred: " + ex.getMessage());
    } else {
        System.out.println("Users list size: " + usersPage.getItems().size());
    }
}).get();

Checklist

@jimmyjames jimmyjames added this to the v1-Next milestone Jan 28, 2021
@jimmyjames jimmyjames requested a review from a team as a code owner January 28, 2021 17:57
@jimmyjames jimmyjames merged commit 5d11019 into master Feb 4, 2021
@jimmyjames jimmyjames deleted the add-async-support branch February 4, 2021 22:15
@jimmyjames jimmyjames mentioned this pull request Feb 5, 2021
3 tasks
@jimmyjames jimmyjames modified the milestones: v1-Next, 1.27.0 Feb 5, 2021
@jimmyjames jimmyjames mentioned this pull request Feb 5, 2021
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support async request execution

2 participants