| SubFlowOperationsThrottleTOut, TMat, TClosed Method (SubFlowTOut, TMat, TClosed, 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.129 (1.2.3.129)
Syntax public static SubFlow<TOut, TMat, TClosed> Throttle<TOut, TMat, TClosed>(
this SubFlow<TOut, TMat, TClosed> flow,
int elements,
TimeSpan per,
int maximumBurst,
ThrottleMode mode
)
[<ExtensionAttribute>]
static member Throttle :
flow : SubFlow<'TOut, 'TMat, 'TClosed> *
elements : int *
per : TimeSpan *
maximumBurst : int *
mode : ThrottleMode -> SubFlow<'TOut, 'TMat, 'TClosed>
Parameters
- flow
- Type: Akka.Streams.DslSubFlowTOut, TMat, TClosed
TBD - elements
- Type: SystemInt32
TBD - per
- Type: SystemTimeSpan
TBD - maximumBurst
- Type: SystemInt32
TBD - mode
- Type: Akka.StreamsThrottleMode
TBD
Type Parameters
- TOut
- TBD
- TMat
- TBD
- TClosed
- TBD
Return Value
Type:
SubFlowTOut,
TMat,
TClosedTBD
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
SubFlowTOut,
TMat,
TClosed. 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