Skip to content

jontore/scala-talk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

scala-talk

Slides

Slide deck

Ecosystem

Akka

http://akka.io

Akka is a toolkit and runtime for building highly concurrent, distributed, and fault tolerant event-driven applications on the JVM

Akka provides fault-tolerance based on supervisor hierarchies. Every actor can create other actors, which it will then supervise, making decisions if they should be resumed, restarted, retired or if the problem should be escalated. Instead of trying all things possible to prevent an error from happening, this approach lets you embrace the reality of unplanned errors.

Example of creating an actor:

case class Greeting(who: String)

class GreetingActor extends Actor with ActorLogging {
  def receive = {
    case Greeting(who) => log.info("Hello " + who)
  }
}

val system = ActorSystem("MySystem")
val greeter = system.actorOf(Props[GreetingActor], name = "greeter")
greeter ! Greeting("Charlie Parker")

Play Framework

(Framework) Built on Akka, Play provides predictable and minimal resource consumption (CPU, memory, threads) for highly-scalable applications.

Main features:

  • native scala support
  • stateless
  • non-blocking I/O
  • built on akka
  • real-time support
  • modular architecture

Example of async I/O:

def index = Action.async {
  val futureInt = Future { intensiveComputation() }
  // Map creates a new future by applying a function to the successful result of this future.
  futureInt.map(i => Ok("Got result: " + i))
}

Resources