Skip to content

Commit

Permalink
add cyclic router and more threads
Browse files Browse the repository at this point in the history
  • Loading branch information
earldouglas committed Sep 12, 2012
1 parent fb5faf5 commit ff6e708
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
10 changes: 9 additions & 1 deletion spray-can/src/main/resources/akka.conf
Expand Up @@ -7,6 +7,14 @@ akka {

event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
event-handler-level = "DEBUG" # Options: ERROR, WARNING, INFO, DEBUG

spray-root-service {
executor = "fork-join-executor"
fork-join-executor {
parallelism-factor = 24
parallelism-max = 24
}
}
}

# spray-can configuration
Expand All @@ -18,7 +26,7 @@ spray-can {
# service-actor-id = "spray-root-service"
# timeout-actor-id = "spray-root-service"
# idle-timeout = 10000
request-timeout = 5000
request-timeout = 15000
}
}

Expand Down
12 changes: 11 additions & 1 deletion spray-can/src/main/scala/scamper/Scamper.scala
Expand Up @@ -4,6 +4,8 @@ import org.slf4j.LoggerFactory

import akka.actor.Actor
import akka.actor.Supervisor
import akka.routing.Routing
import akka.routing.CyclicIterator
import akka.config.Supervision.OneForOneStrategy
import akka.config.Supervision.Permanent
import akka.config.Supervision.Supervise
Expand All @@ -19,7 +21,13 @@ object Boot extends App {

val mainModule = new ScamperService {}

val httpService = Actor.actorOf(new HttpService(mainModule.scamperService))
val scamperActors = for {
_ <- 1 to 24
val actor = Actor.actorOf[ScamperActor]
_ = actor.start
} yield actor

val httpService = Routing.loadBalancerActor(new CyclicIterator(scamperActors))
val rootService = Actor.actorOf(new SprayCanRootService(httpService))
val sprayCanServer = Actor.actorOf(new HttpServer())

Expand All @@ -32,6 +40,8 @@ object Boot extends App {
Supervise(sprayCanServer, Permanent))))
}

class ScamperActor extends HttpService((new ScamperService {}).scamperService)

trait ScamperService extends Directives {

val scamperService = {
Expand Down

0 comments on commit ff6e708

Please sign in to comment.