Sink.ignore
Consume all elements but discards them.
Signature
Description
Consume all elements but discards them. Useful when a stream has to be consumed but there is no use to actually do anything with the elements in the Sink
. Processing of the elements may occur in the Source
/Flow
.
Example
This examples reads lines from a file, saves them to a database, and stores the database identifiers in another file. The stream is run with Sink.ignore
because all processing of the elements have been performed by the preceding stream operators.
- Scala
-
source
val lines: Source[String, NotUsed] = readLinesFromFile() val databaseIds: Source[UUID, NotUsed] = lines.mapAsync(1)(line => saveLineToDatabase(line)) databaseIds.mapAsync(1)(uuid => writeIdToFile(uuid)).runWith(Sink.ignore)
- Java
-
source
Source<String, NotUsed> lines = readLinesFromFile(); Source<UUID, NotUsed> databaseIds = lines.mapAsync(1, line -> saveLineToDatabase(line)); databaseIds.mapAsync(1, uuid -> writeIdToFile(uuid)).runWith(Sink.ignore(), system);
Reactive Streams semantics
cancels never
backpressures never
1.1.2+29-e21fa9eb*