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.