Advertisement
Advertisement

More Related Content

Advertisement
Advertisement

Official "push" and real-time capabilities for Symfony and API Platform (Mercure protocol)

  1. @dunglas A Modern Push Protocol, Natively Supported by Symfony & API Platform
  2. @dunglas Kévin Dunglas ❏ Co-founder of Les-Tilleuls.coop ❏ Creator of Mercure, API Platform and a few more things ❏ Symfony Core Team @dunglas
  3. @dunglas Dev/consulting/training - Lille/Paris ✍ Self-managed since 2011 35 people, 1,000% growth in 6 years 👷 ➡ jobs@les-tilleuls.coop Les-Tilleuls.coop
  4. @dunglas Push, Push, Push!
  5. @dunglas Mercure: Push from Server to Clients ❏ Push notifications ❏ Synchronize connected devices in real-time ❏ Notify users when an async task has finished ❏ Collaborative editing (Google Drive-like) Alternative to WebSocket, socket.io and Pusher
  6. @dunglas Today’s Use Case: Real-Time UI Updates 1. Some data is changed by a user through a form 2. UIs of all connected devices (webapp, smartphone…) instantly display updated data bit.ly/2H17hN3
  7. @dunglas Try it! bit.ly/2H17hN3
  8. @dunglas The Mercure Protocol
  9. @dunglas
  10. @dunglas Mercure, the Protocol ❏ Full-duplex ❏ Built on top of SSEs and HTTP (POST) ❏ Plays well with techs not supporting persistent connections (serverless, PHP…) ❏ Authorization mechanism (private updates) ❏ Built-in reconnection support and retrieving of lost messages ❏ Auto-discoverable, designed for REST and GraphQL APIs ❏ Encryption support
  11. @dunglas Stream events to clients
  12. @dunglas Internet Draft: draft-dunglas-mercure
  13. @dunglas Why Server-Sent Events? ❏ Leverage HTTP/2 (WebSocket doesn’t) ❏ High-level: built-in ❏ re-connection ❏ state reconciliation ❏ Native support in modern browsers ❏ Built on top of HTTP ❏ easy to implement ❏ Pass through all firewalls ❏ Connection-less push proxies (mobile)
  14. @dunglas © Narayan Prusty What is Multiplexing in HTTP/2? HTTP/2 Multiplexing
  15. @dunglas SSEs global support: 89%
  16. @dunglas There is a Polyfill for That! SSEs global support (with polyfill): ~100%
  17. @dunglas The Mercure Hub
  18. @dunglas The Mercure Hub ❏ Implements 100% of the Mercure protocol ❏ Fast, written in Go ❏ Works everywhere: static binaries and Docker ❏ Automatic HTTP/2 and HTTPS ❏ CORS support, CSRF protection ❏ Cloud Native (12Factor App) ❏ Open source (AGPL) Managed and on-premise version available! dunglas+mercure@gmail.com
  19. @dunglas The Mercure Hub https://mercure.rocks
  20. @dunglas Starting the Hub
  21. @dunglas
  22. @dunglas Using Docker
  23. @dunglas Using Docker Compose
  24. @dunglas Publishing
  25. @dunglas Publishing
  26. @dunglas Official component and bundle
  27. @dunglas Official Mercure support in Symfony
  28. @dunglas Configuration
  29. @dunglas Publishing: the Mercure Component
  30. @dunglas Publishing: Messenger Integration
  31. @dunglas Publishing: the Mercure Component
  32. @dunglas Subscribing
  33. @dunglas Subscribing: Basic Usage
  34. @dunglas Subscribing: Several Topics
  35. @dunglas Subscribing: URI Templates
  36. @dunglas The Discovery Mechanism
  37. @dunglas Discovery Mechanism 40
  38. @dunglas Discovery: Server-side
  39. @dunglas Discovery: Client-side
  40. @dunglas Authorization
  41. @dunglas Authorization ❏ Uses JSON Web Token (JWT) ❏ An update can be intended for one or several targets ❏ Publisher: must be authenticated ❏ Subscriber: ❏ Can be anonymous (if allowed by the config) ❏ Must be authenticated to receive updates intended for targets ❏ Two transports: cookie and Authorization header
  42. @dunglas JSON Web Token and Targets
  43. @dunglas Publishing or Subscribing to All Targets
  44. @dunglas Cookie-based Authorization ❏ Set by the app server during the discovery ❏ The app server and the Mercure hub must share the same domain (or subdomain) ❏ Supported by EventSource ❏ Recommended for web browsers
  45. @dunglas Setting the cookie with Symfony
  46. @dunglas HTTP Header-based Authorization ❏ Set by the client ❏ Not supported by native EventSource ❏ Supported by the polyfill ❏ Recommended for servers
  47. @dunglas Publishing to Specific Targets
  48. @dunglas Official server-side and client-side support
  49. @dunglas Mercure Support in API Platform ❏ New in 2.4 ❏ Built on top of the Symfony integration ❏ Mercure Hub provided with ❏ the Docker setup ❏ the Kubernetes chart ❏ Ready to use
  50. @dunglas Auto-dispatch of API Every Updates POST PUT PATCH and DELETE will trigger a Mercure update
  51. @dunglas
  52. @dunglas Scaffolding a React
 Progressive Web App This skeleton is provide in the full API Platform distribution
  53. @dunglas Scaffolding a
 React Native App
  54. @dunglas Mercure, SF and Vue.js? See you in Paris!
  55. @dunglas 62 Thanks! Questions? @dunglas @coopTilleuls
Advertisement