Upgraded routing documentation to Akka 2.0. See #1063
This commit is contained in:
parent
73b79d6e3e
commit
41ce42c8f7
8 changed files with 495 additions and 189 deletions
|
|
@ -0,0 +1,23 @@
|
|||
package akka.docs.routing
|
||||
|
||||
import akka.actor.ActorRef
|
||||
|
||||
//#boundedCapacitor
|
||||
trait BoundedCapacitor {
|
||||
def lowerBound: Int
|
||||
def upperBound: Int
|
||||
|
||||
def capacity(delegates: Seq[ActorRef]): Int = {
|
||||
val current = delegates length
|
||||
var delta = _eval(delegates)
|
||||
val proposed = current + delta
|
||||
|
||||
if (proposed < lowerBound) delta += (lowerBound - proposed)
|
||||
else if (proposed > upperBound) delta -= (proposed - upperBound)
|
||||
|
||||
delta
|
||||
}
|
||||
|
||||
protected def _eval(delegates: Seq[ActorRef]): Int
|
||||
}
|
||||
//#boundedCapacitor
|
||||
Loading…
Add table
Add a link
Reference in a new issue