CircuitBreakerStateReducer
internal class CircuitBreakerStateReducer<T>(val slidingWindow: FailureRateSlidingWindow<T>, val config: CircuitBreakerConfig, val events: MutableSharedFlow<CircuitBreakerEvent>) : Reducer<CircuitBreakerState, CircuitBreakerReducerEvent, CircuitBreakerReducerEffect> (source)
A thread-safe state machine that acts as a reducer for a CircuitBreaker. Using the dispatch method, events can be dispatched to the state machine to trigger state transitions. The current state can be consulted using the currentState method.
Parameters
slidingWindow
the sliding window used to record the result (success or failure) of operations and calculate the failure rate.
config
the configuration of the circuit breaker.
events
the shared flow to emit circuit breaker events to.
Constructors
Link copied to clipboard
constructor(slidingWindow: FailureRateSlidingWindow<T>, config: CircuitBreakerConfig, events: MutableSharedFlow<CircuitBreakerEvent>)
Properties
Functions
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Returns the current state of the reducer.
Link copied to clipboard
Dispatches an event to the reducer to trigger a state transition.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
protected open suspend override fun reducer(state: CircuitBreakerState, event: CircuitBreakerReducerEvent): Pair<CircuitBreakerState, List<CircuitBreakerReducerEffect>>
Given the current state and an event, reduces the event to a new state and a list of effects.
Link copied to clipboard