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

Add support for async requests #328

Merged
merged 3 commits into from
Feb 4, 2021
Merged

Add support for async requests #328

merged 3 commits into from
Feb 4, 2021

Conversation

jimmyjames
Copy link
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