pekko/akka-docs/src/main/paradox/general/code/docs/config/ConfigDocSpec.scala
Arnout Engelen a4a0d308ad 'git mv' rst resources to md
This is mainly intended to keep the git history as neat as possible.
No actual conversion yet, so now both the rst and the paradox docs
are broken, which will be fixed in the next commits.
2017-05-10 15:44:43 +02:00

80 lines
2 KiB
Scala

/**
* Copyright (C) 2009-2017 Lightbend Inc. <http://www.lightbend.com>
*/
package docs.config
import org.scalatest.WordSpec
import org.scalatest.Matchers
import akka.testkit.TestKit
//#imports
import akka.actor.ActorSystem
import com.typesafe.config.ConfigFactory
//#imports
class ConfigDocSpec extends WordSpec with Matchers {
"programmatically configure ActorSystem" in {
//#custom-config
val customConf = ConfigFactory.parseString("""
akka.actor.deployment {
/my-service {
router = round-robin-pool
nr-of-instances = 3
}
}
""")
// ConfigFactory.load sandwiches customConfig between default reference
// config and default overrides, and then resolves it.
val system = ActorSystem("MySystem", ConfigFactory.load(customConf))
//#custom-config
TestKit.shutdownActorSystem(system)
}
"deployment section" in {
val conf = ConfigFactory.parseString("""
#//#deployment-section
akka.actor.deployment {
# '/user/actorA/actorB' is a remote deployed actor
/actorA/actorB {
remote = "akka.tcp://sampleActorSystem@127.0.0.1:2553"
}
# all direct children of '/user/actorC' have a dedicated dispatcher
"/actorC/*" {
dispatcher = my-dispatcher
}
# all descendants of '/user/actorC' (direct children, and their children recursively)
# have a dedicated dispatcher
"/actorC/**" {
dispatcher = my-dispatcher
}
# '/user/actorD/actorE' has a special priority mailbox
/actorD/actorE {
mailbox = prio-mailbox
}
# '/user/actorF/actorG/actorH' is a random pool
/actorF/actorG/actorH {
router = random-pool
nr-of-instances = 5
}
}
my-dispatcher {
fork-join-executor.parallelism-min = 10
fork-join-executor.parallelism-max = 10
}
prio-mailbox {
mailbox-type = "a.b.MyPrioMailbox"
}
#//#deployment-section
""")
val system = ActorSystem("MySystem", conf)
TestKit.shutdownActorSystem(system)
}
}