format source with scalafmt
This commit is contained in:
parent
0f40491d42
commit
ce404e4f53
1669 changed files with 43208 additions and 35404 deletions
|
|
@ -50,7 +50,7 @@ class EchoManager(handlerClass: Class[_]) extends Actor with ActorLogging {
|
|||
}
|
||||
|
||||
// do not restart
|
||||
override def postRestart(thr: Throwable): Unit = context stop self
|
||||
override def postRestart(thr: Throwable): Unit = context.stop(self)
|
||||
|
||||
def receive = {
|
||||
case Bound(localAddress) =>
|
||||
|
|
@ -58,7 +58,7 @@ class EchoManager(handlerClass: Class[_]) extends Actor with ActorLogging {
|
|||
|
||||
case CommandFailed(Bind(_, local, _, _, _)) =>
|
||||
log.warning(s"cannot bind to [$local]")
|
||||
context stop self
|
||||
context.stop(self)
|
||||
|
||||
//#echo-manager
|
||||
case Connected(remote, local) =>
|
||||
|
|
@ -78,14 +78,13 @@ object EchoHandler {
|
|||
Props(classOf[EchoHandler], connection, remote)
|
||||
}
|
||||
|
||||
class EchoHandler(connection: ActorRef, remote: InetSocketAddress)
|
||||
extends Actor with ActorLogging {
|
||||
class EchoHandler(connection: ActorRef, remote: InetSocketAddress) extends Actor with ActorLogging {
|
||||
|
||||
import Tcp._
|
||||
import EchoHandler._
|
||||
|
||||
// sign death pact: this actor terminates when connection breaks
|
||||
context watch connection
|
||||
context.watch(connection)
|
||||
|
||||
// start out in optimistic write-through mode
|
||||
def receive = writing
|
||||
|
|
@ -101,11 +100,11 @@ class EchoHandler(connection: ActorRef, remote: InetSocketAddress)
|
|||
|
||||
case CommandFailed(Write(_, Ack(ack))) =>
|
||||
connection ! ResumeWriting
|
||||
context become buffering(ack)
|
||||
context.become(buffering(ack))
|
||||
|
||||
case PeerClosed =>
|
||||
if (storage.isEmpty) context stop self
|
||||
else context become closing
|
||||
if (storage.isEmpty) context.stop(self)
|
||||
else context.become(closing)
|
||||
}
|
||||
//#writing
|
||||
|
||||
|
|
@ -129,10 +128,10 @@ class EchoHandler(connection: ActorRef, remote: InetSocketAddress)
|
|||
} else {
|
||||
// then return to NACK-based again
|
||||
writeAll()
|
||||
context become (if (peerClosed) closing else writing)
|
||||
context.become(if (peerClosed) closing else writing)
|
||||
}
|
||||
} else if (peerClosed) context stop self
|
||||
else context become writing
|
||||
} else if (peerClosed) context.stop(self)
|
||||
else context.become(writing)
|
||||
}
|
||||
}
|
||||
//#buffering
|
||||
|
|
@ -153,7 +152,7 @@ class EchoHandler(connection: ActorRef, remote: InetSocketAddress)
|
|||
|
||||
case Ack(ack) =>
|
||||
acknowledge(ack)
|
||||
if (storage.isEmpty) context stop self
|
||||
if (storage.isEmpty) context.stop(self)
|
||||
}
|
||||
//#closing
|
||||
|
||||
|
|
@ -181,7 +180,7 @@ class EchoHandler(connection: ActorRef, remote: InetSocketAddress)
|
|||
|
||||
if (stored > maxStored) {
|
||||
log.warning(s"drop connection to [$remote] (buffer overrun)")
|
||||
context stop self
|
||||
context.stop(self)
|
||||
|
||||
} else if (stored > highWatermark) {
|
||||
log.debug(s"suspending reading at $currentOffset")
|
||||
|
|
@ -199,7 +198,7 @@ class EchoHandler(connection: ActorRef, remote: InetSocketAddress)
|
|||
transferred += size
|
||||
|
||||
storageOffset += 1
|
||||
storage = storage drop 1
|
||||
storage = storage.drop(1)
|
||||
|
||||
if (suspended && stored < lowWatermark) {
|
||||
log.debug("resuming reading")
|
||||
|
|
@ -224,13 +223,12 @@ class EchoHandler(connection: ActorRef, remote: InetSocketAddress)
|
|||
//#echo-handler
|
||||
|
||||
//#simple-echo-handler
|
||||
class SimpleEchoHandler(connection: ActorRef, remote: InetSocketAddress)
|
||||
extends Actor with ActorLogging {
|
||||
class SimpleEchoHandler(connection: ActorRef, remote: InetSocketAddress) extends Actor with ActorLogging {
|
||||
|
||||
import Tcp._
|
||||
|
||||
// sign death pact: this actor terminates when connection breaks
|
||||
context watch connection
|
||||
context.watch(connection)
|
||||
|
||||
case object Ack extends Event
|
||||
|
||||
|
|
@ -245,7 +243,7 @@ class SimpleEchoHandler(connection: ActorRef, remote: InetSocketAddress)
|
|||
case PeerClosed => closing = true
|
||||
}, discardOld = false)
|
||||
|
||||
case PeerClosed => context stop self
|
||||
case PeerClosed => context.stop(self)
|
||||
}
|
||||
|
||||
//#storage-omitted
|
||||
|
|
@ -270,7 +268,7 @@ class SimpleEchoHandler(connection: ActorRef, remote: InetSocketAddress)
|
|||
|
||||
if (stored > maxStored) {
|
||||
log.warning(s"drop connection to [$remote] (buffer overrun)")
|
||||
context stop self
|
||||
context.stop(self)
|
||||
|
||||
} else if (stored > highWatermark) {
|
||||
log.debug(s"suspending reading")
|
||||
|
|
@ -286,7 +284,7 @@ class SimpleEchoHandler(connection: ActorRef, remote: InetSocketAddress)
|
|||
stored -= size
|
||||
transferred += size
|
||||
|
||||
storage = storage drop 1
|
||||
storage = storage.drop(1)
|
||||
|
||||
if (suspended && stored < lowWatermark) {
|
||||
log.debug("resuming reading")
|
||||
|
|
@ -295,7 +293,7 @@ class SimpleEchoHandler(connection: ActorRef, remote: InetSocketAddress)
|
|||
}
|
||||
|
||||
if (storage.isEmpty) {
|
||||
if (closing) context stop self
|
||||
if (closing) context.stop(self)
|
||||
else context.unbecome()
|
||||
} else connection ! Write(storage(0), Ack)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue