Slide 1

Slide 1 text

Play and Reactive Streams in 3 minutes Yuta Okamoto (@okapies)
 2015/07/05

Slide 2

Slide 2 text

஫ҙॻ͖ • ຊεϥΠυ͸ɺ6/24 ͷ JJUG Night Seminar Ͱൃදͨ͠ ”Reactive Streams ೖ໳” ͷิ଍ࢿ ྉͰ͢ɻ • ݩࢿྉ΁ͷϦϯΫ͸ˣͷઆ໌ཝʹॻ͍ͯ͋Δ ͷͰɺ͝ڵຯͷ͋Δํ͸ͥͻ͝ࢀর͍ͩ͘͞ɻ

Slide 3

Slide 3 text

֓ཁ ! ! ! ! ͷؔ܎Λ̏෼Ͱઆ໌͢Δɻ Reactive Streams

Slide 4

Slide 4 text

Experimental in Play 2.4 https://www.playframework.com/documentation/2.4.x/Highlights24 Iteratee Λ Reactive
 Streams ʹม׵Ͱ͖Δ

Slide 5

Slide 5 text

ҠߦͷऔΓ૊Έ: Reactive Netty https://github.com/playframework/playframework/issues/4727 Ҡߦ͸ஈ֊తʹ࣮ࢪ

Slide 6

Slide 6 text

࣍ʹى͖Δ͜ͱ (2.5 Ҏ߱) 1. Netty backend → Akka HTTP backend 2. Iteratee → Accumulator with Akka Streams

Slide 7

Slide 7 text

Accumulator final class Accumulator[-E, +A](sink: Sink[E, Future[A]]) { def map[B](f: A => B) (implicit executor: ExecutionContext): Accumulator[E, B] def recoverWith[B >: A](pf: PartialFunction[Throwable, Future[B]]) (implicit executor: ExecutionContext): Accumulator[E, B] ! def run(source: Source[E, _]) (implicit materializer: Materializer): Future[A] =
 source.toMat(sink)(Keep.right).run() } E ܕͷετϦʔϜ (ෳ਺஋) Λ
 Future[A] (୯Ұ஋) ʹ۩ݱԽ͢Δ • Akka Streams (ͷ Sink) ͷബ͍ϥούʔ • ཁૉΛྦྷੵ (accumulate) ݁͠ՌΛ Future ʹม׵ play-streams: play.api.libs.streams.Accumulator

Slide 8

Slide 8 text

Play ͕ Akka ϕʔεͷ FW ʹม਎ http://www.slideshare.net/Typesafe_Inc/reactive-streams-100-and-why-you-should-care-webinar/39

Slide 9

Slide 9 text

͢΂͕ͯ Stream ʹͳΔ ( ʈωʈ)
 ⊃⊂ ͜ΕΛ… http://www.slideshare.net/rolandkuhn/akka-streams-and-http Spary (Akka HTTP ͷલ਎)
 ͷ໰୊఺

Slide 10

Slide 10 text

͢΂͕ͯ Stream ʹͳΔ ( ʈωʈ)
 ⊃ ⊂ ͜͏͡Ό http://www.slideshare.net/rolandkuhn/akka-streams-and-http ڊେϑΝΠϧ΍ chunkɺ
 WebSocket ౳Λ౷Ұతʹ
 ѻ͑ΔΑ͏ʹͳΔ

Slide 11

Slide 11 text

͢΂͕ͯ Akka ʹͳΔ http://tech.iheart.com/post/121599571574/why-we-picked-akka-cluster-as-our-microservice ͜͜΋ ʹͳΔʁ

Slide 12

Slide 12 text

ඇಉظετϦʔϜॲཧͷ՝୊ • ϑϩʔ੍ޚʹࣦഊ͢Δͱ buffer ͕ overflow ͠ɺύΠϓϥΠϯ͕Ϋϥογϡͯ͠ࢮ͵ … > Publisher Subscriber

Slide 13

Slide 13 text

Reactive Streams • ඇಉظετϦʔϜॲཧʹ back-pressure ػߏΛ Ճ͑ͯࣗಈతͳϑϩʔ੍ޚΛ࣮ݱ͢ΔΞΠσΞ • ͜ͷΞΠσΞΛ࣮૷ͨ͠ͷ͕ Reactive Streams ! To be continued…

Slide 14

Slide 14 text

ࢀߟࢿྉ • “Play 3 Implementation Plan” https://docs.google.com/document/ d/1OejviUX5TDlRVeKg1JD9L4qh2Tn21giItmyxRXCydN0/ edit#heading=h.l3a9tmzfgjwy • “Play 2.4͕ґଘੑ஫ೖΛ࠾༻ɼJava 8ʹҠߦ" http:// www.infoq.com/jp/news/2015/06/play-24-dependency-injection • “Reactive Streams and Play 3.0” http://jroper.github.io/play3- streams/ • “Play, Akka streams, and reactive streams” https:// groups.google.com/forum/#!topic/play-framework-dev/ tiHAe23PryQ