开发者

what is the difference between synchronous apis and asynchronous apis?

开发者 https://www.devze.com 2022-12-18 07:22 出处:网络
I want to know about the synchronous apis and asynchronous apis in开发者_运维问答 operating system.

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

精彩评论

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