Repository navigation
evaluate the possibility of Future API surface #533
Description
Activity
- addedADO to GitHub automation labelIssue caused by core project dependency modules or libraryIssue caused by core project dependency modules or library
on Oct 8, 2020 additional information: Future API seems to be here since API level 1 https://developer.android.com/reference/java/util/concurrent/FutureTask?hl=en and java 7 https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Future.html
alternatively the azure identity is using Mono, which requires API level 26 but apparently has a better design
alternatively, android had asyncTask
update: whatever solution we come up with should work with API level 21.
additionally, most http client libraries seem to be providing a native support for Futures (not okhttpclient though)
https://www.mocklab.io/blog/which-java-http-client-should-i-use-in-2020/alternatively, CompletableFuture API level 24 (java allows for chaining the futures (comparatively to "plain" futures)
Recap of the solution and work to be done:
We'll provide a Future API surface which will replace the callback API surface, as having both seems unnecessary and providing a future API surface seems superior to a callback one to comply with our compatibility requirements.
This API surface needs to be wired all the way down to the okhttp call, using FutureTasks, and wrapping the enqueue call. (execute needs to be replaced where used)
Any custom Callback and executor definition needs to be stripped out.We might need to rely on guava's ListenableFutures to chain the work as basic Futures don't seem to provide that kind of support and as CompletableFuture is only available on API level 24.
Lastly, we'll keep providing a synchronous API to align with Azure SDKs
Note: azure provides completable futures and monos in their SDK, but they have separate SDKs for android and java
Update, after investigating and looking in depth at telemetry, we'll switch to CompletableFutures and raise the API level to 26 see the original comment
- linked a pull request that will close this issuefeature/future #610
on Jan 13, 2021
Context: java's equivalent to Promises/Tasks are Futures. Adding an API surface that returns Futures (and potentially removing the callback one??) would enable our customers to write modern Java in their applications
I suppose so but my callback wrapper is pretty straightforward; it wasn't a huge deal writing it.
By far the biggest issue with using graph are the very restrictive rate limits... I shimmed a "rate limiter" into the above wrapper so I'm able to limit both number of simultaneous connections as well as ensure uploads don't go over the 15mb/30 sec limit. It took a lot of trial and error getting the futures passed just right so I didn't go over the max 4 connection cap, but it seems to be working well in practice.
Originally posted by Adam Lesperance (@lespea) in https://github.com/microsoftgraph/msgraph-sdk-java/issue_comments/705202102
AB#6315