Sam Bolgert,“带有Django通道的REST Websockets API”,PyBay2016



通过HTTP构建REST API的问题已经被反复讨论。但是我们可以对WebSockets做同样的事情吗?性能收益是什么?我们可以从HTTP到WS进行哪些学习?本演讲将描述工程师如何使用Django和Channels在WebSockets上构建REST API。它很大程度上基于我尝试构建REST WebSocket API的经验。

抽象
Websocket已经存在了很多年,但是流行的Web框架由于它们的异步特性而使其集成速度很慢。借助Django渠道,我们终于以同步的方式打破了这一领域。开发人员将如何使用这个新领域?我将概述我的一些探索,这些探索已经序列化到一个称为channels-api的库中。它采用Django Rest Framework中熟悉的模式,并将其应用于websocket领域。我将通过一个示例项目来演示该库的配置和安装。我将演示如何使用这些模式来相对快速地创建“类似REST”的API。我们还可以实现HTTP不支持的新功能,例如服务器端推送。

生化
Channels-api库的作者。许多创业公司的前首席工程师。

https://speakerdeck.com/pybay2016/sam-bolgert-rest-websockets-api-with-django-channels。

9 comments
  1. I did everything the same, and it seems to work for me, but I do not understand how the client will listen to the server. The client must listen to the server on the port, and in certain events the server must notify the client. How can a client listen to the port by socket?

  2. Question: Is this good for updates and to subscribe to changes kind of line angulars subscribe were users are being sent noifications of changes ? thanks

Comments are closed.