Esempio n. 1
0
 public CircuitBreaker(CircuitBreakerSetting setting)
 {
     CheckSetting(setting);
     _setting       = setting;
     _closeState    = new CloseState(this, new Tuple <TimeSpan, int>(_setting.AllowFailInterval, _setting.AllowFailTimes));
     _openState     = new OpenState(this, _setting.HalfOpenDuration);
     _halfOpenState = new HalfOpenState(this, _setting.HalfOpenRequestLimit);
     _lockObject    = new object();
     MoveToCloseState();
 }
Esempio n. 2
0
 public void MoveToOpenState()
 {
     _currentState?.Clear();
     _currentState = _openState;
     _currentState.Initialize();
 }
Esempio n. 3
0
 public void MoveToCloseState()
 {
     _currentState?.Clear();
     _currentState = _closeState;
     _currentState.Initialize();
 }