Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
Reactive Streams and the
Wide World of Groovy
Steve Pember
CTO, ThirdChannel
THIRDCHANNEL @svpember
“Reactive Streams”, “Reactive
Extensions”, or “Rx”
THIRDCHANNEL @svpember
Agenda
• The Problem
• What are Reactive Streams?
• … Did someone say ‘Groovy’?
• Rx in depth
• Dem...
THIRDCHANNEL @svpember
The Problem: The Need to go
Reactive
Really, it’s Two problems
THIRDCHANNEL @svpember
1) Performance Demands
Are Always Increasing
We Use Technology from the
Beginning of Web Development
Things Slow Down
Users get
angry
quickly
–Johnny Appleseed
“Type a quote here.”
Let’s Keep Our Users Happy
And Engaged
THIRDCHANNEL @svpember
2) The Rise of Microservices
Multiple
Integration
Points
It’s Not Only Users That Use Up
Resources
So what to do?
Free up resources
with Async
Operations & Non-
Blocking I/O
Async is Hard for Humans
THIRDCHANNEL @svpember
Agenda
• The Problem
• What are Reactive Streams?
Collections + Time
Single abstraction over data
from many sources
THIRDCHANNEL @svpember
Observer Pattern
Push (not Pull)
based Iterators
Stream-Based
Functional Programming
Imperative
vs
Reactive
Stream
Groovy Collections supports
stream-like options
If this makes
sense to
you,
then
you’re
ready for
Rx
Streams with Extensions for
Reactive Programming
Rx makes Async behavior easy!
(Reactive Pull) Backpressure
THIRDCHANNEL @svpember
What is Rx?
• Collections + Time
• A Single Abstraction over data from different sources
• Observer...
Rx Simplifies Complex Work
…Once you
understand,
of course…
THIRDCHANNEL @svpember
Agenda
• The Problem
• What are Reactive Streams?
• … Did someone say ‘Groovy’?
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
We should probably
mention RxJava
Brings
Reactive
Streams to
the JVM
But Quickly Switch to rxGroovy
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
• High performance web framework
• Non-opinionated
• Non-Blocking Network Stack
• Built on Reactive...
http://www.infoq.com/presentations/ratpack-2015
Includes rxRatpack module, but
we’ll talk about that later
THIRDCHANNEL @svpember
Agenda
• The Problem
• What are Reactive Streams?
• … Did someone say ‘Groovy’?
• Rx in depth
… our as much as we can get
through
THIRDCHANNEL @svpember
Key Terms:
An Observable is like Promise ++
An Observable pushes items to
Subscribers
Subscribers receive and
operate on emitted data
Observables and Subscribers
operate on a Scheduler
THIRDCHANNEL @svpember
More Details…
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
Thankfully, there are shortcuts
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
Streams are Composable
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
You can get much power from 5 functions
• filter
• map
• reduce
• groupBy
• flatMap
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
First Mental Leap: An
Observable of Observables
–Johnny Appleseed
“Type a quote here.”
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
Hot vs Cold
Cold Observable: finite data, on
demand
Hot Observable: infinite data, as
it’s ready
THIRDCHANNEL @svpember
Asynchronous Streams
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
BackPressure
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
Can only Mitigate Hot Streams
• throttle
• sample
• window
• buffer
• drop
THIRDCHANNEL @svpember
Stream Interaction
Don’t Unsubscribe from Observables
Programmatically complete them
when another Observable fires
THIRDCHANNEL @svpember
AutoComplete Requirements
• Wait 250 ms between keypresses before querying
• If no keys are pressed...
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
Demo Time: Ratpack Revisited
THIRDCHANNEL @svpember
Any Questions?
Thank You!
@svpember
spember@gmail.com
THIRDCHANNEL @svpember
THIRDCHANNEL @svpember
More Information
• Reactive Groovy & Ratpack Demo: https://github.com/spember/reactive-movie-demo
•...
Images
• Empty Pool: http://www.wtok.com/home/headlines/Water-Problems-205987121.html
• Juggling: https://en.wikipedia.org...
Reactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of Groovy
Próxima SlideShare
Cargando en…5
×

Reactive Streams and the Wide World of Groovy

765 visualizaciones

Publicado el

This talk offers a description of Reactive Streams, along with example code using the Groovy language and rxGroovy

Publicado en: Tecnología
  • Sé el primero en comentar

Reactive Streams and the Wide World of Groovy

  1. 1. Reactive Streams and the Wide World of Groovy Steve Pember CTO, ThirdChannel THIRDCHANNEL @svpember
  2. 2. “Reactive Streams”, “Reactive Extensions”, or “Rx”
  3. 3. THIRDCHANNEL @svpember Agenda • The Problem • What are Reactive Streams? • … Did someone say ‘Groovy’? • Rx in depth • Demo Time!
  4. 4. THIRDCHANNEL @svpember The Problem: The Need to go Reactive
  5. 5. Really, it’s Two problems
  6. 6. THIRDCHANNEL @svpember 1) Performance Demands Are Always Increasing
  7. 7. We Use Technology from the Beginning of Web Development
  8. 8. Things Slow Down
  9. 9. Users get angry quickly
  10. 10. –Johnny Appleseed “Type a quote here.”
  11. 11. Let’s Keep Our Users Happy And Engaged
  12. 12. THIRDCHANNEL @svpember 2) The Rise of Microservices
  13. 13. Multiple Integration Points
  14. 14. It’s Not Only Users That Use Up Resources
  15. 15. So what to do?
  16. 16. Free up resources with Async Operations & Non- Blocking I/O
  17. 17. Async is Hard for Humans
  18. 18. THIRDCHANNEL @svpember Agenda • The Problem • What are Reactive Streams?
  19. 19. Collections + Time
  20. 20. Single abstraction over data from many sources
  21. 21. THIRDCHANNEL @svpember
  22. 22. Observer Pattern Push (not Pull) based Iterators
  23. 23. Stream-Based Functional Programming
  24. 24. Imperative vs Reactive Stream
  25. 25. Groovy Collections supports stream-like options
  26. 26. If this makes sense to you, then you’re ready for Rx
  27. 27. Streams with Extensions for Reactive Programming
  28. 28. Rx makes Async behavior easy!
  29. 29. (Reactive Pull) Backpressure
  30. 30. THIRDCHANNEL @svpember What is Rx? • Collections + Time • A Single Abstraction over data from different sources • Observer Pattern with Push-based iterators • Stream Based Functional Programming • … with Extensions for Reactive Programming • Async is easy • Backpressure
  31. 31. Rx Simplifies Complex Work
  32. 32. …Once you understand, of course…
  33. 33. THIRDCHANNEL @svpember Agenda • The Problem • What are Reactive Streams? • … Did someone say ‘Groovy’?
  34. 34. THIRDCHANNEL @svpember
  35. 35. THIRDCHANNEL @svpember We should probably mention RxJava
  36. 36. Brings Reactive Streams to the JVM
  37. 37. But Quickly Switch to rxGroovy
  38. 38. THIRDCHANNEL @svpember
  39. 39. THIRDCHANNEL @svpember
  40. 40. THIRDCHANNEL @svpember • High performance web framework • Non-opinionated • Non-Blocking Network Stack • Built on Reactive Streams, Netty, Java 8, Guice • Fully embodies reactive • Light-weight, self-contained deployables Take a Look at Ratpack
  41. 41. http://www.infoq.com/presentations/ratpack-2015
  42. 42. Includes rxRatpack module, but we’ll talk about that later
  43. 43. THIRDCHANNEL @svpember Agenda • The Problem • What are Reactive Streams? • … Did someone say ‘Groovy’? • Rx in depth
  44. 44. … our as much as we can get through
  45. 45. THIRDCHANNEL @svpember Key Terms:
  46. 46. An Observable is like Promise ++
  47. 47. An Observable pushes items to Subscribers
  48. 48. Subscribers receive and operate on emitted data
  49. 49. Observables and Subscribers operate on a Scheduler
  50. 50. THIRDCHANNEL @svpember More Details…
  51. 51. THIRDCHANNEL @svpember
  52. 52. THIRDCHANNEL @svpember
  53. 53. Thankfully, there are shortcuts
  54. 54. THIRDCHANNEL @svpember
  55. 55. THIRDCHANNEL @svpember
  56. 56. Streams are Composable
  57. 57. THIRDCHANNEL @svpember
  58. 58. THIRDCHANNEL @svpember You can get much power from 5 functions • filter • map • reduce • groupBy • flatMap
  59. 59. THIRDCHANNEL @svpember
  60. 60. THIRDCHANNEL @svpember
  61. 61. THIRDCHANNEL @svpember
  62. 62. THIRDCHANNEL @svpember
  63. 63. First Mental Leap: An Observable of Observables
  64. 64. –Johnny Appleseed “Type a quote here.”
  65. 65. THIRDCHANNEL @svpember
  66. 66. THIRDCHANNEL @svpember
  67. 67. THIRDCHANNEL @svpember Hot vs Cold
  68. 68. Cold Observable: finite data, on demand Hot Observable: infinite data, as it’s ready
  69. 69. THIRDCHANNEL @svpember Asynchronous Streams
  70. 70. THIRDCHANNEL @svpember
  71. 71. THIRDCHANNEL @svpember
  72. 72. THIRDCHANNEL @svpember
  73. 73. THIRDCHANNEL @svpember BackPressure
  74. 74. THIRDCHANNEL @svpember
  75. 75. THIRDCHANNEL @svpember Can only Mitigate Hot Streams • throttle • sample • window • buffer • drop
  76. 76. THIRDCHANNEL @svpember Stream Interaction
  77. 77. Don’t Unsubscribe from Observables Programmatically complete them when another Observable fires
  78. 78. THIRDCHANNEL @svpember AutoComplete Requirements • Wait 250 ms between keypresses before querying • If no keys are pressed, no query • Successful queries should render movies • Any new queries should kill in-flight queries
  79. 79. THIRDCHANNEL @svpember
  80. 80. THIRDCHANNEL @svpember Demo Time: Ratpack Revisited
  81. 81. THIRDCHANNEL @svpember Any Questions?
  82. 82. Thank You! @svpember spember@gmail.com THIRDCHANNEL @svpember
  83. 83. THIRDCHANNEL @svpember More Information • Reactive Groovy & Ratpack Demo: https://github.com/spember/reactive-movie-demo • Jafar Husain: RxJS: https://www.youtube.com/watch?v=XRYN2xt11Ek • Reactive Streams Spec: http://www.reactive-streams.org/ • Reactive Manifesto: http://www.reactivemanifesto.org/ • Akka: http://akka.io/ • rxJava / ReactiveX libraries: https://github.com/ReactiveX • Ratpack: http://ratpack.io/ • Reactor: https://github.com/reactor/reactor • The Introduction to Reactive Programming you’ve been missing: https://gist.github.com/staltz/868e7e9bc2a7b8c1f754 • Martin Fowler: Stream / Pipeline programming: http://martinfowler.com/articles/refactoring-pipelines.html • Or Just on Groovy (Groovy the Awesome Parts): http://www.slideshare.net/SpringCentral/groovy-the-awesome-parts • Ratpack Web Presentation: http://www.infoq.com/presentations/ratpack-2015
  84. 84. Images • Empty Pool: http://www.wtok.com/home/headlines/Water-Problems-205987121.html • Juggling: https://en.wikipedia.org/wiki/Juggling • Directing Traffic: https://www.flickr.com/photos/tracilawson/3474012583

×