fix compilation of akka-docs
This commit is contained in:
parent
fa94198656
commit
e2f9528bc0
3 changed files with 11 additions and 21 deletions
|
|
@ -5,8 +5,8 @@
|
||||||
//#imports
|
//#imports
|
||||||
package akka.tutorial.first.scala
|
package akka.tutorial.first.scala
|
||||||
|
|
||||||
|
import akka.AkkaApplication
|
||||||
import akka.actor.{ Actor, PoisonPill }
|
import akka.actor.{ Actor, PoisonPill }
|
||||||
import akka.actor.Actor._
|
|
||||||
import akka.routing.Routing.Broadcast
|
import akka.routing.Routing.Broadcast
|
||||||
import akka.routing.{ RoutedProps, Routing }
|
import akka.routing.{ RoutedProps, Routing }
|
||||||
import java.util.concurrent.CountDownLatch
|
import java.util.concurrent.CountDownLatch
|
||||||
|
|
@ -15,6 +15,8 @@ import java.util.concurrent.CountDownLatch
|
||||||
//#app
|
//#app
|
||||||
object Pi extends App {
|
object Pi extends App {
|
||||||
|
|
||||||
|
val app = AkkaApplication()
|
||||||
|
|
||||||
calculate(nrOfWorkers = 4, nrOfElements = 10000, nrOfMessages = 10000)
|
calculate(nrOfWorkers = 4, nrOfElements = 10000, nrOfMessages = 10000)
|
||||||
|
|
||||||
//#actors-and-messages
|
//#actors-and-messages
|
||||||
|
|
@ -66,10 +68,10 @@ object Pi extends App {
|
||||||
|
|
||||||
//#create-workers
|
//#create-workers
|
||||||
// create the workers
|
// create the workers
|
||||||
val workers = Vector.fill(nrOfWorkers)(actorOf[Worker])
|
val workers = Vector.fill(nrOfWorkers)(app.createActor[Worker])
|
||||||
|
|
||||||
// wrap them with a load-balancing router
|
// wrap them with a load-balancing router
|
||||||
val router = Routing.actorOf(RoutedProps().withRoundRobinRouter.withConnections(workers), "pi")
|
val router = app.routing.actorOf(RoutedProps().withRoundRobinRouter.withConnections(workers), "pi")
|
||||||
//#create-workers
|
//#create-workers
|
||||||
|
|
||||||
//#master-receive
|
//#master-receive
|
||||||
|
|
@ -119,7 +121,7 @@ object Pi extends App {
|
||||||
val latch = new CountDownLatch(1)
|
val latch = new CountDownLatch(1)
|
||||||
|
|
||||||
// create the master
|
// create the master
|
||||||
val master = actorOf(new Master(nrOfWorkers, nrOfMessages, nrOfElements, latch))
|
val master = app.createActor(new Master(nrOfWorkers, nrOfMessages, nrOfElements, latch))
|
||||||
|
|
||||||
// start the calculation
|
// start the calculation
|
||||||
master ! Calculate
|
master ! Calculate
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,11 @@ class MyActor extends Actor {
|
||||||
}
|
}
|
||||||
//#my-actor
|
//#my-actor
|
||||||
|
|
||||||
class ActorDocSpec extends WordSpec with MustMatchers with TestKit {
|
class ActorDocSpec extends AkkaSpec {
|
||||||
|
|
||||||
"creating actor with Actor.actorOf" in {
|
"creating actor with AkkaSpec.createActor" in {
|
||||||
//#creating-actorOf
|
//#creating-actorOf
|
||||||
val myActor = Actor.actorOf[MyActor]
|
val myActor = createActor[MyActor]
|
||||||
//#creating-actorOf
|
//#creating-actorOf
|
||||||
|
|
||||||
// testing the actor
|
// testing the actor
|
||||||
|
|
@ -50,26 +50,14 @@ class ActorDocSpec extends WordSpec with MustMatchers with TestKit {
|
||||||
myActor.stop()
|
myActor.stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
"creating actor with imported Actor._" in {
|
|
||||||
//#creating-imported
|
|
||||||
import akka.actor.Actor._
|
|
||||||
|
|
||||||
val myActor = actorOf[MyActor]
|
|
||||||
//#creating-imported
|
|
||||||
|
|
||||||
myActor.stop()
|
|
||||||
}
|
|
||||||
|
|
||||||
"creating actor with constructor" in {
|
"creating actor with constructor" in {
|
||||||
class MyActor(arg: String) extends Actor {
|
class MyActor(arg: String) extends Actor {
|
||||||
def receive = { case _ ⇒ () }
|
def receive = { case _ ⇒ () }
|
||||||
}
|
}
|
||||||
|
|
||||||
import akka.actor.Actor.actorOf
|
|
||||||
|
|
||||||
//#creating-constructor
|
//#creating-constructor
|
||||||
// allows passing in arguments to the MyActor constructor
|
// allows passing in arguments to the MyActor constructor
|
||||||
val myActor = actorOf(new MyActor("..."))
|
val myActor = createActor(new MyActor("..."))
|
||||||
//#creating-constructor
|
//#creating-constructor
|
||||||
|
|
||||||
myActor.stop()
|
myActor.stop()
|
||||||
|
|
|
||||||
|
|
@ -304,7 +304,7 @@ object AkkaBuild extends Build {
|
||||||
lazy val docs = Project(
|
lazy val docs = Project(
|
||||||
id = "akka-docs",
|
id = "akka-docs",
|
||||||
base = file("akka-docs"),
|
base = file("akka-docs"),
|
||||||
dependencies = Seq(actor, testkit, stm, http, remote, slf4j),
|
dependencies = Seq(actor, testkit % "test->test", stm, http, remote, slf4j),
|
||||||
settings = defaultSettings ++ Seq(
|
settings = defaultSettings ++ Seq(
|
||||||
unmanagedSourceDirectories in Test <<= baseDirectory { _ ** "code" get },
|
unmanagedSourceDirectories in Test <<= baseDirectory { _ ** "code" get },
|
||||||
libraryDependencies ++= Dependencies.docs,
|
libraryDependencies ++= Dependencies.docs,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue