pub struct CircuitBreakerBuilder { /* private fields */ }Expand description
Builder for CircuitBreakerInterceptor.
§Example
use rtci_interceptor::{CircuitBreakerBuilder, Registry, Slot};
let (breaker, handle) = CircuitBreakerBuilder::new().build();
let chain = Registry::new().with(Slot::CircuitBreaker, breaker).build();
assert!(handle.ceased().is_empty());Implementations§
Source§impl CircuitBreakerBuilder
impl CircuitBreakerBuilder
Sourcepub fn with_rtcp_interval(self, interval: Duration) -> Self
pub fn with_rtcp_interval(self, interval: Duration) -> Self
Td, this endpoint’s deterministic RTCP reporting interval, computed with Tmin = 5 s (section 4.1). The RTCP timeout breaker trips after three of them. Values above 5 s are held to 5 s: the RFC says not to configure a longer one.
Sourcepub fn with_t_rr_interval(self, interval: Duration) -> Self
pub fn with_t_rr_interval(self, interval: Duration) -> Self
The AVPF T_rr_interval in use, which replaces Tdr in CB_INTERVAL when it is larger
(section 4.3). Held to 4 s (sections 4.1 and 4.3).
Sourcepub fn with_non_reporting_threshold(self, k: u32) -> Self
pub fn with_non_reporting_threshold(self, k: u32) -> Self
k, the number of reports without progress that gives assurance the forward path failed (section 4.2). 5 is recommended.
Sourcepub fn with_frame_group_size(self, frames: u32) -> Self
pub fn with_frame_group_size(self, frames: u32) -> Self
G, the number of frames the codec needs before it can change rate (section 3). 1 for a codec that can adapt on every frame.
Sourcepub fn with_full_tcp_equation(self, full: bool) -> Self
pub fn with_full_tcp_equation(self, full: bool) -> Self
Use the full TCP throughput equation instead of the simplified one (section 4.3: MAY; it is more sensitive to loss and trips earlier).
Sourcepub fn with_packet_size(self, packet_size: PacketSize) -> Self
pub fn with_packet_size(self, packet_size: PacketSize) -> Self
How s, the packet size of the TCP throughput equation, is taken (section 4.3).
PacketSize::SendingWindow by default; PacketSize::LastFrames is section 3’s
“last 4 * G frames”.
Sourcepub fn with_rate_reduction(self, reduce: bool) -> Self
pub fn with_rate_reduction(self, reduce: bool) -> Self
When the congestion breaker trips, first ask for a tenth of the rate
(CircuitBreakerState::Reduced) instead of ceasing at once (section 4.3: MAY). If it
trips again after the next CB_INTERVAL reports the flow ceases.
Sourcepub fn with_grouped_flows(self, group: bool) -> Self
pub fn with_grouped_flows(self, group: bool) -> Self
Treat every flow of the connection as one group: a breaker tripping for one flow applies to all (section 8: MAY). By default each SSRC is judged on its own.
Sourcepub fn with_media_usability(self, usability: MediaUsability) -> Self
pub fn with_media_usability(self, usability: MediaUsability) -> Self
The bound past which the media is unusable (section 4.4). Without one the media usability breaker does not run: the RFC defines no bound.
Sourcepub fn with_automatic_restart(self, automatic: bool) -> Self
pub fn with_automatic_restart(self, automatic: bool) -> Self
Whether the breaker restarts a ceased flow itself when the receiver’s reports show what
stopped it has gone (true, the default), or leaves every restart to the application
(false).
Section 4.5: “RTP flows halted by the circuit breaker SHOULD NOT be restarted automatically unless the sender has received information that the congestion has dissipated or can reasonably be expected to have dissipated.” The information the breaker takes is the receiver’s reports on another flow this endpoint sends on the same transport, received after the flow ceased:
- a flow stopped by the media timeout (4.2, “most likely due to a path failure”) restarts when such a report shows the other flow’s packets arriving: the path delivers;
- a flow stopped by the congestion breaker (4.3) restarts when those reports, over a whole hold, show a loss at which the rate that tripped it is within ten times the TCP throughput again (or no loss at all);
- a flow stopped for unusable media (4.4) restarts when they show loss and round trip time back inside the application’s bound over a whole hold;
- a flow stopped by the RTCP timeout (4.1) restarts when a report on an SSRC this endpoint sends arrives again: “the receiver and return path are working”.
Never before the hold has passed (“the reaction to a triggered circuit breaker lasts
for at least the triggering interval”), and a flow that trips again soon after a
restart is held twice as long each time (up to 64 times the triggering interval), so a
path that keeps failing is tried ever more rarely. When every flow of the transport has
ceased nothing is sent that a report could speak of: the application restarts
(CircuitBreakerHandle::restart) or nobody does.
Sourcepub fn build(self) -> (CircuitBreakerInterceptor, CircuitBreakerHandle)
pub fn build(self) -> (CircuitBreakerInterceptor, CircuitBreakerHandle)
Build the interceptor and the handle the application watches it through.
Sourcepub fn build_with_handle(
self,
handle: &CircuitBreakerHandle,
) -> CircuitBreakerInterceptor
pub fn build_with_handle( self, handle: &CircuitBreakerHandle, ) -> CircuitBreakerInterceptor
Build the interceptor handle watches (made beforehand, for example to give it to the
congestion controller of the same transport). One interceptor per handle.