Click or drag to resize
Akka.NETFlowOperationsThrottleTIn, TOut, TMat Method (FlowTIn, TOut, TMat, Int32, TimeSpan, Int32, FuncTOut, Int32, ThrottleMode)
Sends elements downstream with speed limited to cost/per`. Cost is calculating for each element individually by calling calculateCost function. This combinator works for streams when elements have different cost(length). Streams of ByteString for example. 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 element cost. If there isn't any, throttle waits until the bucket accumulates enough tokens. Elements that costs more than the allowed burst will be delayed proportionally to their cost minus available tokens, meeting the target rate. 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 cost,
	TimeSpan per,
	int maximumBurst,
	Func<TOut, int> calculateCost,
	ThrottleMode mode
)

Parameters

flow
Type: Akka.Streams.DslFlowTIn, TOut, TMat
TBD
cost
Type: SystemInt32
TBD
per
Type: SystemTimeSpan
TBD
maximumBurst
Type: SystemInt32
TBD
calculateCost
Type: SystemFuncTOut, Int32
TBD
mode
Type: Akka.StreamsThrottleMode
TBD

Type Parameters

TIn
TBD
TOut
TBD
TMat
TBD

Return Value

Type: FlowTIn, TOut, TMat
TBD

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).
See Also