=doc #3689 Don't rewrite arrows in doc and samples
This commit is contained in:
parent
37f8f2831b
commit
5a019c0a7a
61 changed files with 531 additions and 517 deletions
|
|
@ -49,14 +49,14 @@ class Listener extends Actor with ActorLogging {
|
|||
context.setReceiveTimeout(15 seconds)
|
||||
|
||||
def receive = {
|
||||
case Progress(percent) ⇒
|
||||
case Progress(percent) =>
|
||||
log.info("Current progress: {} %", percent)
|
||||
if (percent >= 100.0) {
|
||||
log.info("That's all, shutting down")
|
||||
context.system.shutdown()
|
||||
}
|
||||
|
||||
case ReceiveTimeout ⇒
|
||||
case ReceiveTimeout =>
|
||||
// No progress within 15 seconds, ServiceUnavailable
|
||||
log.error("Shutting down due to unavailable service")
|
||||
context.system.shutdown()
|
||||
|
|
@ -83,7 +83,7 @@ class Worker extends Actor with ActorLogging {
|
|||
|
||||
// Stop the CounterService child if it throws ServiceUnavailable
|
||||
override val supervisorStrategy = OneForOneStrategy() {
|
||||
case _: CounterService.ServiceUnavailable ⇒ Stop
|
||||
case _: CounterService.ServiceUnavailable => Stop
|
||||
}
|
||||
|
||||
// The sender of the initial Start message will continuously be notified
|
||||
|
|
@ -94,18 +94,18 @@ class Worker extends Actor with ActorLogging {
|
|||
import context.dispatcher // Use this Actors' Dispatcher as ExecutionContext
|
||||
|
||||
def receive = LoggingReceive {
|
||||
case Start if progressListener.isEmpty ⇒
|
||||
case Start if progressListener.isEmpty =>
|
||||
progressListener = Some(sender)
|
||||
context.system.scheduler.schedule(Duration.Zero, 1 second, self, Do)
|
||||
|
||||
case Do ⇒
|
||||
case Do =>
|
||||
counterService ! Increment(1)
|
||||
counterService ! Increment(1)
|
||||
counterService ! Increment(1)
|
||||
|
||||
// Send current progress to the initial sender
|
||||
counterService ? GetCurrentCount map {
|
||||
case CurrentCount(_, count) ⇒ Progress(100.0 * count / totalCount)
|
||||
case CurrentCount(_, count) => Progress(100.0 * count / totalCount)
|
||||
} pipeTo progressListener.get
|
||||
}
|
||||
}
|
||||
|
|
@ -135,7 +135,7 @@ class CounterService extends Actor {
|
|||
// After 3 restarts within 5 seconds it will be stopped.
|
||||
override val supervisorStrategy = OneForOneStrategy(maxNrOfRetries = 3,
|
||||
withinTimeRange = 5 seconds) {
|
||||
case _: Storage.StorageException ⇒ Restart
|
||||
case _: Storage.StorageException => Restart
|
||||
}
|
||||
|
||||
val key = self.path.name
|
||||
|
|
@ -166,21 +166,21 @@ class CounterService extends Actor {
|
|||
|
||||
def receive = LoggingReceive {
|
||||
|
||||
case Entry(k, v) if k == key && counter == None ⇒
|
||||
case Entry(k, v) if k == key && counter == None =>
|
||||
// Reply from Storage of the initial value, now we can create the Counter
|
||||
val c = context.actorOf(Props(classOf[Counter], key, v))
|
||||
counter = Some(c)
|
||||
// Tell the counter to use current storage
|
||||
c ! UseStorage(storage)
|
||||
// and send the buffered backlog to the counter
|
||||
for ((replyTo, msg) ← backlog) c.tell(msg, sender = replyTo)
|
||||
for ((replyTo, msg) <- backlog) c.tell(msg, sender = replyTo)
|
||||
backlog = IndexedSeq.empty
|
||||
|
||||
case msg @ Increment(n) ⇒ forwardOrPlaceInBacklog(msg)
|
||||
case msg @ Increment(n) => forwardOrPlaceInBacklog(msg)
|
||||
|
||||
case msg @ GetCurrentCount ⇒ forwardOrPlaceInBacklog(msg)
|
||||
case msg @ GetCurrentCount => forwardOrPlaceInBacklog(msg)
|
||||
|
||||
case Terminated(actorRef) if Some(actorRef) == storage ⇒
|
||||
case Terminated(actorRef) if Some(actorRef) == storage =>
|
||||
// After 3 restarts the storage child is stopped.
|
||||
// We receive Terminated because we watch the child, see initStorage.
|
||||
storage = None
|
||||
|
|
@ -189,7 +189,7 @@ class CounterService extends Actor {
|
|||
// Try to re-establish storage after while
|
||||
context.system.scheduler.scheduleOnce(10 seconds, self, Reconnect)
|
||||
|
||||
case Reconnect ⇒
|
||||
case Reconnect =>
|
||||
// Re-establish storage after the scheduled delay
|
||||
initStorage()
|
||||
}
|
||||
|
|
@ -199,8 +199,8 @@ class CounterService extends Actor {
|
|||
// the counter. Before that we place the messages in a backlog, to be sent
|
||||
// to the counter when it is initialized.
|
||||
counter match {
|
||||
case Some(c) ⇒ c forward msg
|
||||
case None ⇒
|
||||
case Some(c) => c forward msg
|
||||
case None =>
|
||||
if (backlog.size >= MaxBacklog)
|
||||
throw new ServiceUnavailable(
|
||||
"CounterService not available, lack of initial value")
|
||||
|
|
@ -230,15 +230,15 @@ class Counter(key: String, initialValue: Long) extends Actor {
|
|||
var storage: Option[ActorRef] = None
|
||||
|
||||
def receive = LoggingReceive {
|
||||
case UseStorage(s) ⇒
|
||||
case UseStorage(s) =>
|
||||
storage = s
|
||||
storeCount()
|
||||
|
||||
case Increment(n) ⇒
|
||||
case Increment(n) =>
|
||||
count += n
|
||||
storeCount()
|
||||
|
||||
case GetCurrentCount ⇒
|
||||
case GetCurrentCount =>
|
||||
sender ! CurrentCount(key, count)
|
||||
|
||||
}
|
||||
|
|
@ -271,8 +271,8 @@ class Storage extends Actor {
|
|||
val db = DummyDB
|
||||
|
||||
def receive = LoggingReceive {
|
||||
case Store(Entry(key, count)) ⇒ db.save(key, count)
|
||||
case Get(key) ⇒ sender ! Entry(key, db.load(key).getOrElse(0L))
|
||||
case Store(Entry(key, count)) => db.save(key, count)
|
||||
case Get(key) => sender ! Entry(key, db.load(key).getOrElse(0L))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue