Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The State of Realtime at &yet

The State of Realtime at &yet

Talk at RealtimeConf 2012.

229ec15028bae7f1d4cdcfe91e2380b0?s=128

Henrik Joreteg

October 24, 2012
Tweet

More Decks by Henrik Joreteg

Other Decks in Technology

Transcript

  1. @HenrikJoreteg + surprise guest The State of Realtime at &yet

    as it pertains to And Bang 2.0 Wednesday, October 24, 12
  2. WHAT ARE WEB APPS REALLY!? Wednesday, October 24, 12

  3. I’D LIKE TO SUGGEST THAT A WEB APP IS... Wednesday,

    October 24, 12
  4. HOSTED SERVICE GOOD AT SOME TYPE OF DATA Wednesday, October

    24, 12
  5. WHAT IS GMAIL’S MAIN INTERFACE? Wednesday, October 24, 12

  6. EMAIL -> GMAIL NOTES -> EVERNOTE TWEETS -> TWITTER CODE

    -> GITHUB Wednesday, October 24, 12
  7. YOUR API BECOMES VERY CORE Wednesday, October 24, 12

  8. SO WE BUILD RESTFUL APIS RIGHT? Wednesday, October 24, 12

  9. LET’S DIGRESS... Wednesday, October 24, 12

  10. SHORTCOMINGS OF REST+HTTP Wednesday, October 24, 12

  11. CRUD IN REST: Create -> POST Read -> GET Update

    -> PUT Delete -> DELETE Wednesday, October 24, 12
  12. POST /user/47?addToGroup=friends How do you link an existing user to

    an existing group? Wednesday, October 24, 12
  13. PUT /user/47 body: { addToGroup: “friends” } How do you

    link an existing user to an existing group? Wednesday, October 24, 12
  14. Or are you actually editing the group? PUT /group/friends?addUser=47 How

    do you link an existing user to an existing group? Wednesday, October 24, 12
  15. WEB API != REST Wednesday, October 24, 12

  16. WEB API ~= REST (for my fellow redis-lua scripters) Wednesday,

    October 24, 12
  17. YOUR API IS A SET OF FUNCTIONALITY: addUserToGroup(47, “friends”) Wednesday,

    October 24, 12
  18. WHAT DO WE REALLY WANT FROM AN API? Wednesday, October

    24, 12
  19. MULTIPLE WAYS OF GETTING DATA IN AND OUT Wednesday, October

    24, 12
  20. SIMPLE UNIFIED AUTHENTICATION Wednesday, October 24, 12

  21. SIMPLE UNIFIED AUTHENTICATION (since that doesn’t exist we have to

    settle for OAuth 2.0) Wednesday, October 24, 12
  22. THE OFFICIAL APP IS JUST ANOTHER CLIENT OF THE PUBLIC

    API Wednesday, October 24, 12
  23. FULL DATA EVENTING Wednesday, October 24, 12

  24. WHAT ABOUT REALTIME? Wednesday, October 24, 12

  25. HTTP IS NOT PUSH Wednesday, October 24, 12

  26. Wednesday, October 24, 12

  27. WebSockets Wednesday, October 24, 12

  28. WebSockets ServerSent Events Wednesday, October 24, 12

  29. WebSockets ServerSent Events XMPP Wednesday, October 24, 12

  30. WebSockets ServerSent Events XMPP Socket.io Wednesday, October 24, 12

  31. WebSockets ServerSent Events XMPP Socket.io Long-Polling Wednesday, October 24, 12

  32. WebSockets ServerSent Events XMPP Socket.io Long-Polling Animated GIF Streaming!? Wednesday,

    October 24, 12
  33. DO WE THROW REST+HTTP OUT? Wednesday, October 24, 12

  34. WebSockets ServerSent Events XMPP Socket.io Long-Polling Animated GIF Streaming!? Wednesday,

    October 24, 12
  35. WebSockets ServerSent Events XMPP Socket.io Long-Polling Animated GIF Streaming!? HTTP

    Wednesday, October 24, 12
  36. SEE ALL OF THESE FOR WHAT THEY ARE: TRANSPORTS Wednesday,

    October 24, 12
  37. ADAPTERS/TRANSPORTS TO THE ONE TRUE API Wednesday, October 24, 12

  38. OUR ATTEMPT AT BUILDING THIS... Wednesday, October 24, 12

  39. WE BUILT A SPEC Wednesday, October 24, 12

  40. WE BUILD EVERYTHING OFF THAT SPEC Wednesday, October 24, 12

  41. (SPEC) Wednesday, October 24, 12

  42. Wednesday, October 24, 12

  43. HTTP REST Wednesday, October 24, 12

  44. HTTP REST SOCKET.IO Wednesday, October 24, 12

  45. HTTP REST SOCKET.IO ANDBANG.JS Wednesday, October 24, 12

  46. HTTP REST SOCKET.IO ANDBANG.JS UNIT TESTS Wednesday, October 24, 12

  47. HTTP REST SOCKET.IO ANDBANG.JS UNIT TESTS DOCS APP Wednesday, October

    24, 12
  48. ANY TIME DATA CHANGES AN EVENT IS PUBLISHED THAT DESCRIBES

    THE CHANGES Wednesday, October 24, 12
  49. SOUNDS GREAT BUT HOW?! Wednesday, October 24, 12

  50. {{ @fritzy }} Wednesday, October 24, 12

  51. DIFFERENT TRANSPORTS DIFFERENT FEATURES Wednesday, October 24, 12

  52. Event type: shipTask { "eventNumber": 4270, "action": {.. metadata about

    the event type ..}, "category": "team", "instance": "1", "crud": [ { "id": "338", "type": "update", "object": "task", "data": {.. changed attributes ..} }, { "id": "2320", "type": "create", "object": "chat", "data": {.. attributes of chat message ..} } ] } Wednesday, October 24, 12
  53. // full client synchronization in ~ 20 LOC api.on(‘*’, function

    (eventType, data) { if (data.crud) { data.crud.forEach(function (crudItem) { if (crudItem.type === ‘update’) { // look up our model in memory var model = app.getModel(crudItem.object, crudItem.id); // if we find it, set our data if (model) model.set(crudItem.data); } else if (crudItem.type === ‘create’) { // create it and add it } else if (crudItem.type === ‘delete’) { // find it and delete it if found } }); } }); Wednesday, October 24, 12
  54. (DEMO) Wednesday, October 24, 12

  55. WHAT DOES ALL THIS MEAN? Wednesday, October 24, 12

  56. THANKS! @HenrikJoreteg, @fritzy, @andyet, @andbang on twitter Wednesday, October 24,

    12