object StreamConverters
Converters for interacting with the blocking java.io
streams APIs and Java 8 Streams
- Source
- StreamConverters.scala
- Alphabetic
- By Inheritance
- StreamConverters
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def asInputStream(readTimeout: Duration): Sink[ByteString, InputStream]
Creates a Sink which when materialized will return an java.io.InputStream which it is possible to read the values produced by the stream this Sink is attached to.
Creates a Sink which when materialized will return an java.io.InputStream which it is possible to read the values produced by the stream this Sink is attached to.
This Sink is intended for inter-operation with legacy APIs since it is inherently blocking.
You can configure the internal buffer size by using pekko.stream.ActorAttributes.
The InputStream will be closed when the stream flowing into this Sink completes, and closing the InputStream will cancel this Sink.
- readTimeout
the max time the read operation on the materialized InputStream should block
- Annotations
- @nowarn()
- def asInputStream(): Sink[ByteString, InputStream]
Creates a Sink which when materialized will return an java.io.InputStream which it is possible to read the values produced by the stream this Sink is attached to.
Creates a Sink which when materialized will return an java.io.InputStream which it is possible to read the values produced by the stream this Sink is attached to.
This method uses a default read timeout, use #inputStream(FiniteDuration) or #inputStream(java.time.Duration) to explicitly configure the timeout.
This Sink is intended for inter-operation with legacy APIs since it is inherently blocking.
You can configure the internal buffer size by using pekko.stream.ActorAttributes.
The InputStream will be closed when the stream flowing into this Sink completes, and closing the InputStream will cancel this Sink.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def asJavaStream[T](): Sink[T, Stream[T]]
Creates a sink which materializes into Java 8
that can be run to trigger demand through the sink.Stream
Creates a sink which materializes into Java 8
that can be run to trigger demand through the sink. Elements emitted through the stream will be available for reading through the Java 8Stream
.Stream
The Java 8
will be ended when the stream flowing into thisStream
completes, and closing the JavaSink
will cancel the inflow of thisStream
.Sink
Java 8
throws exception in case reactive stream failed.Stream
Be aware that Java
blocks current thread while waiting on next element from downstream. As it is interacting wit blocking API the implementation runs on a separate dispatcher configured through theStream
.pekko.stream.blocking-io-dispatcher
- def asOutputStream(): Source[ByteString, OutputStream]
Creates a Source which when materialized will return an java.io.OutputStream which it is possible to write the ByteStrings to the stream this Source is attached to.
Creates a Source which when materialized will return an java.io.OutputStream which it is possible to write the ByteStrings to the stream this Source is attached to. The write timeout for OutputStreams materialized will default to 5 seconds, @see #outputStream(FiniteDuration) or #outputStream(java.time.Duration) if you want to override it.
This Source is intended for inter-operation with legacy APIs since it is inherently blocking.
You can configure the internal buffer size by using pekko.stream.ActorAttributes.
The created OutputStream will be closed when the Source is cancelled, and closing the OutputStream will complete this Source.
- def asOutputStream(writeTimeout: Duration): Source[ByteString, OutputStream]
Creates a Source which when materialized will return an java.io.OutputStream which it is possible to write the ByteStrings to the stream this Source is attached to.
Creates a Source which when materialized will return an java.io.OutputStream which it is possible to write the ByteStrings to the stream this Source is attached to.
This Source is intended for inter-operation with legacy APIs since it is inherently blocking.
You can configure the default dispatcher for this Source by changing the
pekko.stream.materializer.blocking-io-dispatcher
or set it for a given Source by using pekko.stream.ActorAttributes.The created OutputStream will be closed when the Source is cancelled, and closing the OutputStream will complete this Source.
- writeTimeout
the max time the write operation on the materialized OutputStream should block
- Annotations
- @nowarn()
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def fromInputStream(in: Creator[InputStream]): Source[ByteString, CompletionStage[IOResult]]
Creates a Source from an java.io.InputStream created by the given function.
Creates a Source from an java.io.InputStream created by the given function. Emitted elements are up to 8192 bytes sized pekko.util.ByteString elements. The actual size of the emitted elements depends on how much data the underlying java.io.InputStream returns on each read invocation. Such chunks will never be larger than chunkSize though.
You can configure the default dispatcher for this Source by changing the
pekko.stream.materializer.blocking-io-dispatcher
or set it for a given Source by using pekko.stream.ActorAttributes.It materializes a CompletionStage of IOResult containing the number of bytes read from the source file upon completion, and a possible exception if IO operation was not completed successfully.
The created InputStream will be closed when the Source is cancelled.
- def fromInputStream(in: Creator[InputStream], chunkSize: Int): Source[ByteString, CompletionStage[IOResult]]
Creates a Source from an java.io.InputStream created by the given function.
Creates a Source from an java.io.InputStream created by the given function. Emitted elements are up to
chunkSize
sized pekko.util.ByteString elements. The actual size of the emitted elements depends on how much data the underlying java.io.InputStream returns on each read invocation. Such chunks will never be larger than chunkSize though.You can configure the default dispatcher for this Source by changing the
pekko.stream.materializer.blocking-io-dispatcher
or set it for a given Source by using pekko.stream.ActorAttributes.It materializes a CompletionStage of IOResult containing the number of bytes read from the source file upon completion, and a possible exception if IO operation was not completed successfully. Note that bytes having been read by the source does not give any guarantee that the bytes were seen by downstream stages.
The created InputStream will be closed when the Source is cancelled.
- def fromJavaStream[O, S <: BaseStream[O, S]](stream: Creator[BaseStream[O, S]]): Source[O, NotUsed]
Creates a source that wraps a Java 8
.Stream
Creates a source that wraps a Java 8
.Stream
uses a stream iterator to get all its elements and send them downstream on demand.Source
Example usage:
Source.fromJavaStream(() -> IntStream.rangeClosed(1, 10))
You can use Source.async to create asynchronous boundaries between synchronous java stream and the rest of flow.
- def fromOutputStream(f: Creator[OutputStream], autoFlush: Boolean): Sink[ByteString, CompletionStage[IOResult]]
Sink which writes incoming ByteStrings to an OutputStream created by the given function.
Sink which writes incoming ByteStrings to an OutputStream created by the given function.
Materializes a CompletionStage of IOResult that will be completed with the size of the file (in bytes) at the streams completion, and a possible exception if IO operation was not completed successfully.
You can configure the default dispatcher for this Source by changing the
pekko.stream.materializer.blocking-io-dispatcher
or set it for a given Source by using pekko.stream.ActorAttributes.The OutputStream will be closed when the stream flowing into this Sink is completed. The Sink will cancel the stream when the OutputStream is no longer writable.
- f
A Creator which creates an OutputStream to write to
- autoFlush
If true the OutputStream will be flushed whenever a byte array is written
- def fromOutputStream(f: Creator[OutputStream]): Sink[ByteString, CompletionStage[IOResult]]
Sink which writes incoming ByteStrings to an OutputStream created by the given function.
Sink which writes incoming ByteStrings to an OutputStream created by the given function.
Materializes a CompletionStage of IOResult that will be completed with the size of the file (in bytes) at the streams completion, and a possible exception if IO operation was not completed successfully.
You can configure the default dispatcher for this Source by changing the
pekko.stream.materializer.blocking-io-dispatcher
or set it for a given Source by using pekko.stream.ActorAttributes.This method uses no auto flush for the java.io.OutputStream @see Boolean) if you want to override it.
The OutputStream will be closed when the stream flowing into this Sink is completed. The Sink will cancel the stream when the OutputStream is no longer writable.
- f
A Creator which creates an OutputStream to write to
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def javaCollector[T, R](collector: Creator[Collector[T, _, R]]): Sink[T, CompletionStage[R]]
Creates a sink which materializes into a
which will be completed with a result of the Java 8CompletionStage
transformation and reduction operations.Collector
Creates a sink which materializes into a
which will be completed with a result of the Java 8CompletionStage
transformation and reduction operations. This allows usage of Java 8 streams transformations for reactive streams. The CollectorCollector
Collectorwill trigger demand downstream. Elements emitted through the stream will be accumulated into a mutable result container, optionally transformed into a final representation after all input elements have been processed. The
can also do reduction at the end. Reduction processing is performed sequentially
Note that a flow can be materialized multiple times, so the function producing the
must be able to handle multiple invocations.Collector
- def javaCollectorParallelUnordered[T, R](parallelism: Int)(collector: Creator[Collector[T, _, R]]): Sink[T, CompletionStage[R]]
Creates a sink which materializes into a
which will be completed with a result of the Java 8CompletionStage
transformation and reduction operations.Collector
Creates a sink which materializes into a
which will be completed with a result of the Java 8CompletionStage
transformation and reduction operations. This allows usage of Java 8 streams transformations for reactive streams. TheCollector
will trigger demand downstream. Elements emitted through the stream will be accumulated into a mutable result container, optionally transformed into a final representation after all input elements have been processed.Collector
can also do reduction at the end. Reduction processing is performed in parallel based on graphCollector
.Balance
Note that a flow can be materialized multiple times, so the function producing the
must be able to handle multiple invocations.Collector
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def asInputStream(readTimeout: FiniteDuration): Sink[ByteString, InputStream]
Creates a Sink which when materialized will return an java.io.InputStream which it is possible to read the values produced by the stream this Sink is attached to.
Creates a Sink which when materialized will return an java.io.InputStream which it is possible to read the values produced by the stream this Sink is attached to.
This Sink is intended for inter-operation with legacy APIs since it is inherently blocking.
You can configure the internal buffer size by using pekko.stream.ActorAttributes.
The InputStream will be closed when the stream flowing into this Sink completes, and closing the InputStream will cancel this Sink.
- readTimeout
the max time the read operation on the materialized InputStream should block
- Annotations
- @deprecated
- Deprecated
(Since version Akka 2.5.12) Use the overloaded one which accepts java.time.Duration instead.
- def asOutputStream(writeTimeout: FiniteDuration): Source[ByteString, OutputStream]
Creates a Source which when materialized will return an java.io.OutputStream which it is possible to write the ByteStrings to the stream this Source is attached to.
Creates a Source which when materialized will return an java.io.OutputStream which it is possible to write the ByteStrings to the stream this Source is attached to.
This Source is intended for inter-operation with legacy APIs since it is inherently blocking.
You can configure the internal buffer size by using pekko.stream.ActorAttributes.
The created OutputStream will be closed when the Source is cancelled, and closing the OutputStream will complete this Source.
- writeTimeout
the max time the write operation on the materialized OutputStream should block
- Annotations
- @deprecated
- Deprecated
(Since version Akka 2.5.12) Use the overloaded one which accepts java.time.Duration instead.
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated @Deprecated
- Deprecated