-
Notifications
You must be signed in to change notification settings - Fork 301
Description
Pending on #413
Go does not have a predefined construct for async/concurrent work like Promise/Task/Futures in other languages. We're currently generating async methods using a callback signature (returning a func), this approach is not super convenient for callers.
Feedback from @JeffreyRichter on an internal thread:
you should absolutely not provide async APIs in a Go library as this causes harm (additional resource consumption & perf slowdowns) and zero benefit whatsoever – this is just not how Go and its goroutines work
A few alternatives to consider for async work:
- Generate a synchronous API instead and let callers wrap the calls in go routines (easily done by changing the return type IsAsync to false)
- Use channels instead which brings syntax complexity and questions around errors management. They also seem to be more adapted to concurrent datasets processing than to IO/network async usage.
- Other option? (lib?)
Logging this issue so we can discuss the course of actions. So far Kiota has taken the approach of only delivering Async APIs. We might deliver sync APIs as well for languages that provide async constructs, but those sync APIs would only be a wrapper around the async ones.
CC @darrelmiller on the architecture aspects. Should we allow platforms/languages to differ on that aspect?