Skip to content

Instantly share code, notes, and snippets.

View ihrimech's full-sized avatar

Ismail Hrimech ihrimech

View GitHub Profile
@ihrimech
ihrimech / HumanWithResponses.scala
Last active May 16, 2019 08:10
A simple Human Actor with some reaction to the messages from the object HumanObjectMin.scala
class Human extends Actor with ActorLogging {
override def receive: Receive = {
case Hello => log.info("Hello dear :)")
case HowAreYou => log.info("I'm fine dude, thanks for asking")
case HowIAm(happy) =>
if (happy) log.info("I am Groot")
else log.info("Well, have a kitkat")
}
}
@ihrimech
ihrimech / HumanObjectMin.scala
Last active May 16, 2019 08:09
companion object of the minimal Human actor
object Human {
def props = Props[Human]
// Saying Hello
case object Hello
// Asking how Someone is
case object HowAreYou
// response to someone asking how we are
@ihrimech
ihrimech / HumanMinimal.scala
Last active May 15, 2019 14:45
Minimal Actor Class
class Human extends Actor with ActorLogging {
override def receive: Receive = {
case message: String => log.info(s"I received the following message $message")
}
}
@ihrimech
ihrimech / build.sbt
Last active May 15, 2019 13:17
sbt minimal file for an Akka application
name := "akka-quickstart-scala"
version := "1.0"
scalaVersion := "2.12.6"
lazy val akkaVersion = "2.5.22"
libraryDependencies ++= Seq(
// la seule dépendance dont on aura besoin pour l'instant sera celle du core d'Akka