what is the difference between synchronous apis and asynchronous apis?
I want to know about the synchronous apis and asynchronous apis in开发者_运维问答 operating system. What is the difference between them ?
A synchronous API will block the caller until it returns. An asynchronous API will not block the caller and typically will require a callback which will be executed once the work is completed.
Blocking
Callback
You can have the same in Web APIs. Some APIs will return data in the body of the result of the calls and others will just return (e.g.) a 202 and then do something in the background (processing data, setting up a subscription). Webhooks are then a common way to ping you back when the job you requested is "done".
At 3scale, we use use both synchronous and asynchronous modes with webhooks to avoid people having to couple too tightly to systems.
精彩评论