Search Results for

    Show / Hide Table of Contents

    Class StreamConverters

    Converters for interacting with the IO streams APIs

    Inheritance
    object
    StreamConverters
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Akka.Streams.Dsl
    Assembly: Akka.Streams.dll
    Syntax
    public static class StreamConverters

    Methods

    | Edit this page View Source

    AsInputStream(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
    TimeSpan? readTimeout

    The max time the read operation on the materialized stream should block

    Returns
    Type Description
    Sink<ByteString, Stream>

    TBD

    | Edit this page View Source

    AsOutputStream(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
    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

    | Edit this page View Source

    FromInputStream(Func<Stream>, int)

    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

    int chunkSize

    The size of each read operation, defaults to 8192

    Returns
    Type Description
    Source<ByteString, Task<IOResult>>

    TBD

    | Edit this page View Source

    FromOutputStream(Func<Stream>, bool)

    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

    bool 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

    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET