1 / 10

Akka

Akka. Quick Intro for hAkkers. What is it?. Toolkit for development of scalable distributed fault-tolerant applications in Scala or Java. Modules Offered. actors (typed / untyped / testkit) very slick Futures / Promises STM async-http camel spring cluster (upcoming in 2.0)

Download Presentation

Akka

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Akka Quick Intro for hAkkers

  2. What is it? Toolkit for development of • scalable • distributed • fault-tolerant applications in Scala or Java Roland Kuhn @ Scalathon

  3. Modules Offered • actors (typed / untyped / testkit) • very slick Futures / Promises • STM • async-http • camel • spring • cluster (upcoming in 2.0) • … (to be filled, possibly by you!) Roland Kuhn @ Scalathon

  4. Project Details • site at http://akka.io • source at https://github.com/jboner/akka • https://www.assembla.com/spaces/akka for tickets (need to “watch” the space) • Apache License 2.0 • Contributor’s License Agreement needed for submissions Roland Kuhn @ Scalathon

  5. Hacking Guide • Performance is King! • memory footprint • minimize allocations • avoid blocking operations • Every feature or fix needs a corresponding test case • Always update docs together with code • reStructured Text within git repo Roland Kuhn @ Scalathon

  6. Goals for Scalathon • Hack demo application • get feedback on API & docs • get feedback on testkit • contribute to improve experience for newcomers Roland Kuhn @ Scalathon

  7. Getting Started • Strong encapsulation of Actor • only access through ActorRef • only constructible inside factory method • no calling of Actor methods from the outside, except through mailbox • Communication via Channel[T] • allows sending • may be passed around Roland Kuhn @ Scalathon

  8. import akka.actor._ class A extendsActor { defreceive = { case“ping” => self reply“pong” } } class B(a: ActorRef) extendsActor { var last: UntypedChannel = NullChannel defreceive = { case“ping” => last = self.channel a !“ping” case“pong” => last safe_!“pong” } } import org.scalatest.WordSpec import org.scalatest.matchers.MustMatchers import akka.testkit.TestKit import akka.util.duration._ class ABSpec extends WordSpec with MustMatchers withTestKit { “Some B” must { “return answer obtained from A” in { val a = actorOf[A].start() val b = actorOf(new B(a)).start() within(500 millis) { b !“ping” expectMsg(“pong”) } } } } Actor Sample Roland Kuhn @ Scalathon

  9. Future Sample import akka.dispatch.Future import Future.flow val x = Future(calculateSomeExpensiveInt()) val y = Future(calculateSomeExpensiveFloat()) val z = flow { val f = someActor ?x() // someActor will reply at some point with a Float Some(f() / y()) } recover { case _: ArithmeticException => None } z onResult { case Some(x) => doSomething(x) case None => log.error(“calculation failed”) } val result = z.await.result// if you must really block Roland Kuhn @ Scalathon

  10. Conclusion • Forget what you knew about “composing” concurrent programs • View actors as fundamental building blocks encapsulating state • Go wild! Roland Kuhn @ Scalathon

More Related