Skip to content

Commit

Permalink
Minor clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane Landelle committed Apr 2, 2013
1 parent 4bc44a7 commit 8e2dd4c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ import io.gatling.core.session.Session

import akka.actor.ActorRef

class Switch(strategy: () => ActorRef, val next: ActorRef) extends Bypassable {
class Switch(nextAction: () => ActorRef, val next: ActorRef) extends Bypassable {

def execute(session: Session) {

val nextAction = strategy()
nextAction ! session
nextAction() ! session
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RandomSwitchBuilder(possibilities: List[(Int, ChainBuilder)]) extends Acti
(percentage, possibilityAction)
}

val strategy = () => {
val nextAction = () => {

@tailrec
def determineNextAction(index: Int, possibilities: List[(Int, ActorRef)]): ActorRef = possibilities match {
Expand All @@ -50,6 +50,6 @@ class RandomSwitchBuilder(possibilities: List[(Int, ChainBuilder)]) extends Acti
determineNextAction(ThreadLocalRandom.current.nextInt(1, 101), possibleActions)
}

system.actorOf(Props(new Switch(strategy, next)))
system.actorOf(Props(new Switch(nextAction, next)))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class RoundRobinSwitchBuilder(possibilities: List[ChainBuilder]) extends ActionB

val rr = RoundRobin(possibleActions)

val strategy = () => rr.next
val nextAction = () => rr.next

system.actorOf(Props(new Switch(strategy, next)))
system.actorOf(Props(new Switch(nextAction, next)))
}
}

0 comments on commit 8e2dd4c

Please sign in to comment.