Click or drag to resize
Akka.NETSourceUnfoldResourceT, TSource Method
Start a new SourceTOut, TMat from some resource which can be opened, read and closed. Interaction with resource happens in a blocking way. Example: {{{ Source.unfoldResource( () => new BufferedReader(new FileReader("...")), reader => Option(reader.readLine()), reader => reader.close()) }}} You can use the supervision strategy to handle exceptions for read function. All exceptions thrown by create or close will fail the stream. Restart supervision strategy will close and create blocking IO again. Default strategy is Stop which means that stream will be terminated on error in `read` function by default. 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).

Namespace:  Akka.Streams.Dsl
Assembly:  Akka.Streams (in Akka.Streams.dll) Version: 1.2.3.42 (1.2.3.42)
Syntax
public static Source<T, NotUsed> UnfoldResource<T, TSource>(
	Func<TSource> create,
	Func<TSource, Option<T>> read,
	Action<TSource> close
)

Parameters

create
Type: SystemFuncTSource
function that is called on stream start and creates/opens resource.
read
Type: SystemFuncTSource, OptionT
function that reads data from opened resource. It is called each time backpressure signal is received. Stream calls close and completes when read returns None.
close
Type: SystemActionTSource
TBD

Type Parameters

T
TBD
TSource
TBD

Return Value

Type: SourceT, NotUsed
TBD
See Also