Click or drag to resize
Akka.NETSubFlowOperationsThrottleTOut, TMat, TClosed Method (SubFlowTOut, TMat, TClosed, 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.129 (1.2.3.129)
Syntax
public static SubFlow<TOut, TMat, TClosed> Throttle<TOut, TMat, TClosed>(
	this SubFlow<TOut, TMat, TClosed> flow,
	int cost,
	TimeSpan per,
	int maximumBurst,
	Func<TOut, int> calculateCost,
	ThrottleMode mode
)

Parameters

flow
Type: Akka.Streams.DslSubFlowTOut, TMat, TClosed
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

TOut
TBD
TMat
TBD
TClosed
TBD

Return Value

Type: SubFlowTOut, TMat, TClosed
TBD

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