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
import akka.dispatch.Future | |
import akka.pattern.pipe | |
import akka.actor.Actor | |
case class Work(s: String) | |
case class Result(s: String) | |
object MyActor { | |
// put here to avoid closing over actor’s state | |
def doWork(work: String): String = { |
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 typedactordemo | |
import akka.actor._ | |
import akka.dispatch.Future | |
import akka.pattern.ask | |
import akka.util.Timeout | |
import akka.util.duration._ | |
case class Request(payload: String) | |
case class Response(payload: String) |
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
import sbt._ | |
import Keys._ | |
import classpath.ClasspathUtilities.isArchive | |
import java.io.FileOutputStream | |
import sbtassembly.Plugin._ | |
import AssemblyKeys._ | |
object B extends Build { | |
lazy val merge = TaskKey[File]("merge-reference", | |
"merge all reference.conf") |
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
set resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/" | |
set libraryDependencies ++= Seq("com.typesafe.akka" % "akka-actor" % "2.0.1", "com.typesafe.akka" % "akka-remote" % "2.0.1", "com.typesafe.akka" % "akka-testkit" % "2.0.1" % "test", "org.specs2" %% "specs2" % "1.9" % "test", "junit" % "junit" % "4.5" % "test") |
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
/** | |
* Copyright (C) 2012 Typesafe Inc. <http://www.typesafe.com> | |
*/ | |
package docs.testkit; | |
import org.junit.AfterClass; | |
import org.junit.Assert; | |
import org.junit.BeforeClass; | |
import org.junit.Test; |
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
import akka.actor.ActorDSL._ | |
val ref = actor("fred")(new Act { | |
become { | |
case "hello" => sender ! "world!" | |
} | |
}) | |
implicit val recv = inbox() | |
ref ! "hello" // uses the `recv` as sender ref |
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
new JavaTestKit(system) {{ | |
final Props props = new Props(SomeActor.class); | |
final ActorRef subject = system.actorOf(props); | |
subject.tell("request", getRef()); | |
expectMsgEquals(duration("1 second"), "response"); | |
new Within(duration("3 seconds")) { | |
protected void run() { | |
subject.tell("hello", getRef()); |
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
import akka.actor.ActorDSL._ | |
case object Work | |
case object StopIt | |
implicit val system = akka.actor.ActorSystem() | |
actor(new Act { | |
case class ToDo(items: Int, client: ActorRef, v: Double) | |
become { |
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
Welcome to Scala version 2.10.0-RC5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_07). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> system=ActorSystem("repl",ConfigFactory.parseString("pinned{type=PinnedDispatcher;executor=thread-pool-executor}").withFallback(config)) | |
[DEBUG] [12/09/2012 21:23:23.535] [run-main] [EventStream(akka://repl)] logger log1-Logging$DefaultLogger started | |
[DEBUG] [12/09/2012 21:23:23.535] [run-main] [EventStream(akka://repl)] Default Loggers started | |
system: akka.actor.ActorSystem = akka://repl | |
scala> case class Add(x: Int) |
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
def eval(code: String, compileOptions: String = | |
"-cp akka-actor/target/classes:akka-macros/target/classes"): Any = { | |
val tb = mkToolbox(compileOptions) | |
tb.eval(tb.parse(code)) | |
} | |
def mkToolbox(compileOptions: String = ""): ToolBox[_ <: Universe] = { | |
val m = scala.reflect.runtime.currentMirror | |
m.mkToolBox(options = compileOptions) | |
} |
OlderNewer