Class StreamConverters
Converters for interacting with the IO streams APIs
Inherited Members
Namespace: Akka.Streams.Dsl
Assembly: Akka.Streams.dll
Syntax
public static class StreamConverters
Methods
| Improve this Doc View SourceAsInputStream(Nullable<TimeSpan>)
Creates a Sink which when materialized will return an Stream 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 default dispatcher for this Source by changing the "akka.stream.blocking-io-dispatcher" or set it for a given Source by using CreateDispatcher(String).
The Stream will be closed when the stream flowing into this Sink<TIn, TMat> completes, and closing the Stream will cancel this Sink<TIn, TMat>.
Declaration
public static Sink<ByteString, Stream> AsInputStream(TimeSpan? readTimeout = null)
Parameters
Type | Name | Description |
---|---|---|
Nullable<TimeSpan> | readTimeout | The max time the read operation on the materialized stream should block |
Returns
Type | Description |
---|---|
Sink<ByteString, Stream> | TBD |
AsOutputStream(Nullable<TimeSpan>)
Creates a Source<TOut, TMat> which when materialized will return an Stream 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 "akka.stream.blocking-io-dispatcher" or set it for a given Source by using CreateDispatcher(String).
The created Stream will be closed when the Source<TOut, TMat> is cancelled, and closing the Stream will complete this Source<TOut, TMat>.
Declaration
public static Source<ByteString, Stream> AsOutputStream(TimeSpan? writeTimeout = null)
Parameters
Type | Name | Description |
---|---|---|
Nullable<TimeSpan> | writeTimeout | The max time the write operation on the materialized OutputStream should block, defaults to 5 seconds |
Returns
Type | Description |
---|---|
Source<ByteString, Stream> | TBD |
FromInputStream(Func<Stream>, Int32)
Creates a Source<TOut, TMat> from an Stream created by the given function.
Emitted elements are chunkSize
sized ByteString elements.
The actual size of emitted elements depends how much data the underlying
Stream 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 "akka.stream.blocking-io-dispatcher" or set it for a given Source by using CreateDispatcher(String).
It materializes a Task<TResult> 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 Stream will be closed when the Source<TOut, TMat> is cancelled.Declaration
public static Source<ByteString, Task<IOResult>> FromInputStream(Func<Stream> createInputStream, int chunkSize = 8192)
Parameters
Type | Name | Description |
---|---|---|
Func<Stream> | createInputStream | A function which creates the Stream to read from |
Int32 | chunkSize | The size of each read operation, defaults to 8192 |
Returns
Type | Description |
---|---|
Source<ByteString, Task<IOResult>> | TBD |
FromOutputStream(Func<Stream>, Boolean)
Creates a Sink which writes incoming ByteStrings to an Stream created by the given function.
Materializes a Task<TResult> 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 "akka.stream.blocking-io-dispatcher" or
set it for a given Source by using CreateDispatcher(String).
If autoFlush
is true the OutputStream will be flushed whenever a byte array is written, defaults to false.
The Stream will be closed when the stream flowing into this Sink<TIn, TMat> is completed. The Sink<TIn, TMat> will cancel the stream when the Stream is no longer writable.
Declaration
public static Sink<ByteString, Task<IOResult>> FromOutputStream(Func<Stream> createOutputStream, bool autoFlush = false)
Parameters
Type | Name | Description |
---|---|---|
Func<Stream> | createOutputStream | A function which creates the Stream to write to |
Boolean | autoFlush | If set to true the Stream will be flushed whenever a byte array is written, default is false |
Returns
Type | Description |
---|---|
Sink<ByteString, Task<IOResult>> | TBD |