Title: evaluate the possibility of Future API surface · Issue #533 · microsoftgraph/msgraph-sdk-java · GitHub
Open Graph Title: evaluate the possibility of Future API surface · Issue #533 · microsoftgraph/msgraph-sdk-java
X Title: evaluate the possibility of Future API surface · Issue #533 · microsoftgraph/msgraph-sdk-java
Description: 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 ...
Open Graph Description: 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...
X Description: 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 Jav...
Opengraph URL: https://github.com/microsoftgraph/msgraph-sdk-java/issues/533
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"evaluate the possibility of Future API surface","articleBody":"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\r\n\r\nI suppose so but my callback wrapper is pretty straightforward; it wasn't a huge deal writing it.\r\n\r\n```scala\r\nobject ICallbackWrapper extends StrictLogging {\r\n\r\n private def cbF[T](): (Future[T], ICallback[T]) = {\r\n val p = Promise[T]()\r\n val cb = new ICallback[T] {\r\n override def success(result: T): Unit = {\r\n val _ = p.trySuccess(result)\r\n }\r\n\r\n override def failure(ex: ClientException): Unit = {\r\n val _ = p.tryFailure(ex)\r\n }\r\n }\r\n\r\n (p.future, cb)\r\n }\r\n\r\n def toFut[T](fun: ICallback[T] => Unit)(\r\n implicit\r\n ec: ExecutionContext,\r\n ): Future[T] = {\r\n val (f, cb) = cbF[T]()\r\n\r\n Limiter.apiFut {\r\n () =>\r\n fun(cb)\r\n f\r\n }\r\n }\r\n\r\n def toFut[V, T](v: V, fun: (V, ICallback[T]) => Unit)(\r\n implicit\r\n ec: ExecutionContext,\r\n ): Future[T] = {\r\n val (f, cb) = cbF[T]()\r\n\r\n Limiter.apiFut {\r\n () =>\r\n fun(v, cb)\r\n f\r\n }\r\n }\r\n\r\n def uploadFut[V, T](v: V, len: Long, fun: (V, ICallback[T]) => Unit)(\r\n implicit\r\n ec: ExecutionContext,\r\n ): Future[T] = {\r\n val (f, cb) = cbF[T]()\r\n\r\n Limiter.attachFut(\r\n () => {\r\n fun(v, cb)\r\n f\r\n },\r\n len,\r\n )\r\n }\r\n}\r\n```\r\n\r\nBy 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.\r\n\r\n_Originally posted by @lespea in https://github.com/microsoftgraph/msgraph-sdk-java/issue_comments/705202102_ \r\n[AB#6315](https://microsoftgraph.visualstudio.com/0985d294-5762-4bc2-a565-161ef349ca3e/_workitems/edit/6315)","author":{"url":"https://github.com/baywet","@type":"Person","name":"baywet"},"datePublished":"2020-10-08T12:06:23Z","url":"https://github.com/microsoftgraph/msgraph-sdk-java/issues/533"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a2c0ed7d-50dc-60b8-f286-70d4b9c13632 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9B90:3EE5E8:1226CE4:17BC1A5:6B053A9B |
| html-safe-nonce | b49c4891bf2e5c7d23beba6f4191e2d9e7e4f3e24862174f7555353f8b18149a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QjkwOjNFRTVFODoxMjI2Q0U0OjE3QkMxQTU6NkIwNTNBOUIiLCJ2aXNpdG9yX2lkIjoiMjMwNjc3MzIyMjU5NTc3NDk5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 2fc7a2257c1ec0e8e533448728eebd2b4465a48bd89309d5f0f83e6cad1d2d45 |
| hovercard-subject-tag | issue:717284760 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoftgraph/msgraph-sdk-java/533/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7813ec9292c5fa3d87156e432c4608fe67d28cd228c476ef8b31afa42649beac/microsoftgraph/msgraph-sdk-java/issues/533 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7813ec9292c5fa3d87156e432c4608fe67d28cd228c476ef8b31afa42649beac/microsoftgraph/msgraph-sdk-java/issues/533 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | baywet |
| hostname | github.com |
| expected-hostname | github.com |
| None | 854d880890b5e847b3fce9d1b31f032107baeddeebad2aa379c48aa4f1451f6b |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoftgraph/msgraph-sdk-java git https://github.com/microsoftgraph/msgraph-sdk-java.git |
| octolytics-dimension-user_id | 17304259 |
| octolytics-dimension-user_login | microsoftgraph |
| octolytics-dimension-repository_id | 103300409 |
| octolytics-dimension-repository_nwo | microsoftgraph/msgraph-sdk-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 103300409 |
| octolytics-dimension-repository_network_root_nwo | microsoftgraph/msgraph-sdk-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 220e980097d94ce616d5d11fbd5316d208e3fc93 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width