!str split Framing into javadsl and scaladsl
This commit is contained in:
parent
5d3a8256c1
commit
c25e0abab6
14 changed files with 178 additions and 23 deletions
|
|
@ -7,7 +7,7 @@ import java.util.concurrent.CompletionStage;
|
|||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import akka.NotUsed;
|
||||
import akka.stream.io.Framing;
|
||||
import akka.stream.javadsl.Framing;
|
||||
import docs.AbstractJavaTest;
|
||||
import docs.stream.SilenceSystemOut;
|
||||
import java.net.InetSocketAddress;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import akka.NotUsed;
|
|||
import akka.actor.ActorSystem;
|
||||
import akka.stream.ActorMaterializer;
|
||||
import akka.stream.Materializer;
|
||||
import akka.stream.io.Framing;
|
||||
import akka.stream.javadsl.Framing;
|
||||
import akka.stream.javadsl.Sink;
|
||||
import akka.stream.javadsl.Source;
|
||||
import akka.testkit.JavaTestKit;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ which will emit an :class:`IncomingConnection` element for each new connection t
|
|||
Next, we simply handle *each* incoming connection using a :class:`Flow` which will be used as the processing stage
|
||||
to handle and emit ByteStrings from and to the TCP Socket. Since one :class:`ByteString` does not have to necessarily
|
||||
correspond to exactly one line of text (the client might be sending the line in chunks) we use the ``delimiter``
|
||||
helper Flow from ``akka.stream.io.Framing`` to chunk the inputs up into actual lines of text. The last boolean
|
||||
helper Flow from ``akka.stream.javadsl.Framing`` to chunk the inputs up into actual lines of text. The last boolean
|
||||
argument indicates that we require an explicit line ending even for the last message before the connection is closed.
|
||||
In this example we simply add exclamation marks to each incoming text message and push it through the flow:
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
package docs.http.scaladsl.server.directives
|
||||
|
||||
import akka.http.scaladsl.model._
|
||||
import akka.stream.io.Framing
|
||||
import akka.stream.scaladsl.Framing
|
||||
import akka.util.ByteString
|
||||
import docs.http.scaladsl.server.RoutingSpec
|
||||
import scala.concurrent.Future
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class RecipeParseLines extends RecipeSpec {
|
|||
ByteString("\r\n\r\n")))
|
||||
|
||||
//#parse-lines
|
||||
import akka.stream.io.Framing
|
||||
import akka.stream.scaladsl.Framing
|
||||
val linesStream = rawData.via(Framing.delimiter(
|
||||
ByteString("\r\n"), maximumFrameLength = 100, allowTruncation = true))
|
||||
.map(_.utf8String)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class StreamTcpDocSpec extends AkkaSpec {
|
|||
{
|
||||
val (host, port) = TestUtils.temporaryServerHostnameAndPort()
|
||||
//#echo-server-simple-handle
|
||||
import akka.stream.io.Framing
|
||||
import akka.stream.scaladsl.Framing
|
||||
|
||||
val connections: Source[IncomingConnection, Future[ServerBinding]] =
|
||||
Tcp().bind(host, port)
|
||||
|
|
@ -66,7 +66,7 @@ class StreamTcpDocSpec extends AkkaSpec {
|
|||
val connections = Tcp().bind(localhost.getHostName, localhost.getPort) // TODO getHostString in Java7
|
||||
val serverProbe = TestProbe()
|
||||
|
||||
import akka.stream.io.Framing
|
||||
import akka.stream.scaladsl.Framing
|
||||
//#welcome-banner-chat-server
|
||||
|
||||
connections.runForeach { connection =>
|
||||
|
|
@ -97,7 +97,7 @@ class StreamTcpDocSpec extends AkkaSpec {
|
|||
}
|
||||
//#welcome-banner-chat-server
|
||||
|
||||
import akka.stream.io.Framing
|
||||
import akka.stream.scaladsl.Framing
|
||||
|
||||
val input = new AtomicReference("Hello world" :: "What a lovely day" :: Nil)
|
||||
def readLine(prompt: String): String = {
|
||||
|
|
|
|||
|
|
@ -189,3 +189,10 @@ Replace with::
|
|||
|
||||
http.cachedHostConnectionPool(toHostHttps("akka.io", 8081), materializer());
|
||||
http.cachedHostConnectionPool(toHostHttps("akka.io", 8081).withCustomHttpsContext(httpsContext), materializer());
|
||||
|
||||
Framing moved to akka.stream.[javadsl/scaladsl]
|
||||
-----------------------------------------------
|
||||
|
||||
The ``Framing`` object which can be used to chunk up ``ByteString`` streams into
|
||||
framing dependent chunks (such as lines) has moved to ``akka.stream.scaladsl.Framing``,
|
||||
and has gotten a Java DSL equivalent type in ``akka.stream.javadsl.Framing``.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue