Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Latest commit

 

History

History
36 lines (31 loc) · 1.16 KB

akka-rules.md

File metadata and controls

36 lines (31 loc) · 1.16 KB

Akka rules package rules/akka

These rules should apply to code that uses the Akka framework. The provided rules require the libraries

"com.typesafe.akka" %% "akka-actor" % "2.3.3"
"com.typesafe.akka" %% "akka-stream-experimental" % "0.4"

TODO: this requirement should be made more flexible by people who know more about Akka than I do!

Sender method called in deferred block

name : sender-in-future
source : SenderInFuture

The sender() method should never be called inside of a code block that won't be executed immediately in the receive method since the resulting sender might not be the right one anymore when the deferred code is actually executed. For example, the code

class ExampleActor extends Actor {
  def receive = {
    case "Hi" => future {
      sender() ! "Hello"
    }
  }
}

should be written as

class ExampleActor extends Actor {
  def receive = {
    case "Hi" => 
      val s = sender()
      future { s ! "Hello" }
  }
}

to make sure the sender we use to reply is indeed the one associated to the received message.