Last active
September 29, 2016 22:55
-
-
Save retroryan/35f212a8b7c827d72b16ae5f8e632f0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
akka { | |
loggers = [akka.event.slf4j.Slf4jLogger] | |
loglevel = DEBUG | |
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter" | |
actor { | |
debug { | |
unhandled = on | |
} | |
} | |
} | |
akka { | |
loggers = [akka.event.slf4j.Slf4jLogger] | |
loglevel = DEBUG | |
logging-filter = "akka.event.slf4j.Slf4jLoggingFilter" | |
actor { | |
debug { | |
lifecycle = on | |
unhandled = on | |
} | |
} | |
} | |
coffee-house { | |
guest { | |
finish-coffee-duration = 2 seconds | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override val supervisorStrategy: SupervisorStrategy = { | |
val decider: SupervisorStrategy.Decider = { | |
case Guest.CaffeineException => | |
SupervisorStrategy.Stop | |
case Waiter.FrustratedException(coffee, guest) => | |
barista.tell(Barista.PrepareCoffee(coffee, guest), sender()) | |
SupervisorStrategy.Restart | |
} | |
OneForOneStrategy()(decider orElse super.supervisorStrategy.decider) | |
} | |
private val duration: Long = context.system.settings.config.getDuration("coffee-house.guest.finish-coffee-duration", MILLISECONDS) | |
private val guestFinishCoffeeDuration = | |
Duration(duration, MILLISECONDS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
system.actorOf(Props(new Actor with ActorLogging { | |
coffeeHouse ! "Brew Coffee" | |
override def receive: Receive = { | |
case message => log.info(message.toString) | |
} | |
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://docs.scala-lang.org/cheatsheets/ | |
http://twitter.github.io/scala_school/pattern-matching-and-functional-composition.html | |
https://github.com/lampepfl/progfun-wiki/blob/gh-pages/CheatSheet.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.typesafe.training.coffeehouse | |
import akka.actor.{ Actor, Props } | |
object Waiter { | |
case class ServeCoffee(coffee: Coffee) | |
case class CoffeeServed(coffee: Coffee) | |
def props: Props = | |
Props(new Waiter) | |
} | |
class Waiter extends Actor { | |
import Waiter._ | |
override def receive: Receive = { | |
case ServeCoffee(coffee) => sender() ! CoffeeServed(coffee) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment