SE2016 Exotic Oleg Gorbunov "Action cable"
-
Upload
inhacking -
Category
Technology
-
view
64 -
download
5
Transcript of SE2016 Exotic Oleg Gorbunov "Action cable"
ActionCable и с чем его едят
Main feature
The two star features of Rails 5.0 are as follows:
• Action Cable • API mode
Что еще за ВебСокеты?
Это та крутая тема, которую чуваки на
Node.js используют?
Я слышал за сокетами будущее
Full-duplex это в 2 раза круче чем half-
duplex, так ведь? Realtime и Full-duplex? звучит круто, добавлю в резюме
HTML в древности
Simple, stateless, looks like MVP for WEB
Новые потребности
Клиенту нужно часто отправлять запросы на
сервер
Клиенту нужно часто получать обновления с
сервера
Streaming
в том числе
Other Realtime solutions
Polling
Long-polling
Server-Sent Events
Polling
Hey! Hey server! You got any new data? Server? SERVER!.
Long-polling
Server-Sent Events (SSE)
ActionController::Live
How WebSockets Work?
Persistent stateful connectionLightweight metadata
- upgrade request (652 bytes) - and no more
Full-duplex communication
Caniuseit?
Откуда растут ноги
FreeriderRails API, ActionCable, React, MaterialUI
FreeriderGame page
API overview
Connection
Channel
Channels
Sending Messages
Javascript
Code
• 450 LOC of javascript • 2200 LOC of ruby
Other Options
MessageBus Sync ActionController::Live
faye-websocket-ruby
websocket-rails em-websocket
MessageBus
• simple api • polling, long-polling or streaming • supports server-server, client-server communication
Sync
• update partials with web sockets • you need manually call sync_update(@user)
ActionController::Live• simple API • not for IE • doesn’t work with heroku, unicorn
faye-websocket-ruby• uses Faye for pub/sub • separate process, no access to rails code • more work to do
websocket-rails• dead • integrates well with Rails
em-websocket• looks like faye-websocket-ruby • updated 2 years ago
Конклюжены
• loosing caching, routing, multiplexing, gzipping and lot more
• good for cases with rapid communication • simple and fun • all-in-box • fast start • rails integration • npm-package • works with heroku • good prospectives
Sources I am thankful for:1. http://tenderlovemaking.com/2012/07/30/is-it-live.html 2. https://www.sitepoint.com/websockets-in-the-ruby-ecosystem 3. https://www.nateberkopec.com/2015/09/30/action-cable.html 4. http://edgeguides.rubyonrails.org/action_cable_overview.html 5. https://www.sitepoint.com/action-cable-and-websockets-an-in-depth-tutorial 6. https://github.com/websocket-rails/websocket-rails 7. https://github.com/rails/rails/tree/master/actioncable 8. https://github.com/chrismccord/sync 9. https://github.com/SamSaffron/message_bus 10. http://edgeguides.rubyonrails.org/action_cable_overview.html
Author: Oleg Gorbunov game: http://freerider.herokuapp.com email: [email protected] linkedin: https://ua.linkedin.com/in/oleggorbunov