!str - 18916 - Source.file and Sink.file
* Removes `Synchronous` from the names and descriptions of File I/O as it leaks impl details * Removes the factries for FileSource and FileSink and puts them in Source and Sink respectively
This commit is contained in:
parent
7d4304fc6e
commit
20c996fe41
31 changed files with 262 additions and 242 deletions
|
|
@ -1,5 +1,7 @@
|
|||
package docs
|
||||
|
||||
import java.io.File
|
||||
|
||||
import akka.http.scaladsl.model.Uri
|
||||
import akka.stream.scaladsl._
|
||||
import akka.stream._
|
||||
|
|
@ -208,6 +210,14 @@ class MigrationsScala extends AkkaSpec {
|
|||
//#query-param
|
||||
val param: Option[String] = uri.query().get("a")
|
||||
//#query-param
|
||||
|
||||
//#file-source-sink
|
||||
val fileSrc = Source.file(new File("."))
|
||||
|
||||
val otherFileSrc = Source.file(new File("."), 1024)
|
||||
|
||||
val someFileSink = Sink.file(new File("."))
|
||||
//#file-source-sink
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import akka.http.scaladsl.model.headers.{ Server, RawHeader }
|
|||
import akka.http.scaladsl.server.RouteResult.{ Complete, Rejected }
|
||||
import akka.http.scaladsl.server._
|
||||
import akka.stream.ActorMaterializer
|
||||
import akka.stream.io.SynchronousFileSource
|
||||
import akka.stream.scaladsl.{ Sink, Source }
|
||||
import akka.util.ByteString
|
||||
|
||||
|
|
@ -174,7 +173,7 @@ class BasicDirectivesExamplesSpec extends RoutingSpec {
|
|||
path("sample") {
|
||||
complete {
|
||||
// internally uses the configured fileIODispatcher:
|
||||
val source = SynchronousFileSource(new File("example.json"))
|
||||
val source = Source.file(new File("example.json"))
|
||||
HttpResponse(entity = HttpEntity(ContentTypes.`application/json`, source))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ package docs.stream.io
|
|||
import java.io.File
|
||||
|
||||
import akka.stream._
|
||||
import akka.stream.io.SynchronousFileSink
|
||||
import akka.stream.io.SynchronousFileSource
|
||||
import akka.stream.scaladsl.Sink
|
||||
import akka.stream.scaladsl.Source
|
||||
import akka.stream.testkit.Utils._
|
||||
|
|
@ -48,7 +46,7 @@ class StreamFileDocSpec extends AkkaSpec(UnboundedMailboxConfig) {
|
|||
|
||||
//#file-source
|
||||
|
||||
val foreach: Future[Long] = SynchronousFileSource(file)
|
||||
val foreach: Future[Long] = Source.file(file)
|
||||
.to(Sink.ignore)
|
||||
.run()
|
||||
//#file-source
|
||||
|
|
@ -56,16 +54,8 @@ class StreamFileDocSpec extends AkkaSpec(UnboundedMailboxConfig) {
|
|||
|
||||
"configure dispatcher in code" in {
|
||||
//#custom-dispatcher-code
|
||||
SynchronousFileSink(file)
|
||||
Sink.file(file)
|
||||
.withAttributes(ActorAttributes.dispatcher("custom-blocking-io-dispatcher"))
|
||||
//#custom-dispatcher-code
|
||||
}
|
||||
|
||||
"show Implicits" in {
|
||||
//#source-sink-implicits
|
||||
import akka.stream.io.Implicits._
|
||||
|
||||
Source.synchronousFile(file) to Sink.outputStream(() ⇒ System.out)
|
||||
//#source-sink-implicits
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue