开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜