| FlowOperationsThrottleTIn, TOut, TMat Method (FlowTIn, TOut, TMat, Int32, TimeSpan, Int32, ThrottleMode) |
Sends elements downstream with speed limited to
elements/
per. In other words, this stage set the maximum rate
for emitting messages. This combinator works for streams where all elements have the same cost or length.
Throttle implements the token bucket model. There is a bucket with a given token capacity (burst size or maximumBurst).
Tokens drops into the bucket at a given rate and can be "spared" for later use up to bucket capacity
to allow some burstiness. Whenever stream wants to send an element, it takes as many
tokens from the bucket as number of elements. If there isn't any, throttle waits until the
bucket accumulates enough tokens.
Parameter
mode manages behaviour when upstream is faster than throttle rate:
-
Shaping makes pauses before emitting messages to meet throttle rate
-
Enforcing fails with exception when upstream is faster than throttle rate. Enforcing
cannot emit elements that cost more than the maximumBurst
Emits when upstream emits an element and configured time per each element elapsed
Backpressures when downstream backpressures
Completes when upstream completes
Cancels when downstream cancels
Namespace:
Akka.Streams.Dsl
Assembly:
Akka.Streams (in Akka.Streams.dll) Version: 1.2.3.42 (1.2.3.42)
Syntax public static Flow<TIn, TOut, TMat> Throttle<TIn, TOut, TMat>(
this Flow<TIn, TOut, TMat> flow,
int elements,
TimeSpan per,
int maximumBurst,
ThrottleMode mode
)
[<ExtensionAttribute>]
static member Throttle :
flow : Flow<'TIn, 'TOut, 'TMat> *
elements : int *
per : TimeSpan *
maximumBurst : int *
mode : ThrottleMode -> Flow<'TIn, 'TOut, 'TMat>
Parameters
- flow
- Type: Akka.Streams.DslFlowTIn, TOut, TMat
TBD - elements
- Type: SystemInt32
TBD - per
- Type: SystemTimeSpan
TBD - maximumBurst
- Type: SystemInt32
TBD - mode
- Type: Akka.StreamsThrottleMode
TBD
Type Parameters
- TIn
- TBD
- TOut
- TBD
- TMat
- TBD
Return Value
Type:
FlowTIn,
TOut,
TMatTBD
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
FlowTIn,
TOut,
TMat. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
Exceptions Exception | Condition |
---|
ArgumentException | Thrown when elements is less than or equal zero,
or per timeout is equal Zero
or maximumBurst is less than or equal zero in in Enforcingmode. |
See Also