Class KillSwitches
Creates shared or single kill switches which can be used to control completion of graphs from the outside.
- The factory Shared(String) returns a SharedKillSwitch which provides a IGraph<TShape> of FlowShape<TIn, TOut> that can be used in arbitrary number of graphs and materializations. The switch simultaneously controls completion in all of those graphs.
- The factory Single<T>() returns a IGraph<TShape> of FlowShape<TIn, TOut> that materializes to a UniqueKillSwitch which is always unique to that materialized Flow itself.
Inherited Members
Namespace: Akka.Streams
Assembly: Akka.Streams.dll
Syntax
public static class KillSwitches
Methods
| Improve this Doc View SourceAsFlow<T>(CancellationToken, Boolean)
Returns a flow, which works like a kill switch stage based on a provided cancellationToken
.
Since unlike cancellation tokens, kill switches expose ability to finish a stream either gracefully via
Shutdown() or abruptly via Abort(Exception), this distinction is
handled by specifying cancelGracefully
parameter.
Declaration
public static IGraph<FlowShape<T, T>, NotUsed> AsFlow<T>(this CancellationToken cancellationToken, bool cancelGracefully = false)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | Cancellation token used to create a cancellation flow. |
Boolean | cancelGracefully | When set to true, will close stream gracefully via completting the stage. When set to false, will close stream by failing the stage with OperationCanceledException. |
Returns
Type | Description |
---|---|
IGraph<FlowShape<T, T>, NotUsed> |
Type Parameters
Name | Description |
---|---|
T |
Shared(String)
Creates a new SharedKillSwitch with the given name that can be used to control the completion of multiple streams from the outside simultaneously.
Declaration
public static SharedKillSwitch Shared(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | TBD |
Returns
Type | Description |
---|---|
SharedKillSwitch | TBD |
Single<T>()
Creates a new IGraph<TShape> of FlowShape<TIn, TOut> that materializes to an external switch that allows external completion of that unique materialization. Different materializations result in different, independent switches.
For a Bidi version see SingleBidi<T1, T2>()
Declaration
public static IGraph<FlowShape<T, T>, UniqueKillSwitch> Single<T>()
Returns
Type | Description |
---|---|
IGraph<FlowShape<T, T>, UniqueKillSwitch> | TBD |
Type Parameters
Name | Description |
---|---|
T | TBD |
SingleBidi<T1, T2>()
Creates a new IGraph<TShape> of BidiShape<TIn1, TOut1, TIn2, TOut2> that materializes to an external switch that allows external completion of that unique materialization. Different materializations result in different, independent switches.
For a Flow version see Single<T>()
Declaration
public static IGraph<BidiShape<T1, T1, T2, T2>, UniqueKillSwitch> SingleBidi<T1, T2>()
Returns
Type | Description |
---|---|
IGraph<BidiShape<T1, T1, T2, T2>, UniqueKillSwitch> | TBD |
Type Parameters
Name | Description |
---|---|
T1 | TBD |
T2 | TBD |