Ejemplo n.º 1
0
 /**
  * Allows you to set a breaker onto the board that you may have created elsewhere.
  *
  * @param   CircuitBreaker  $breaker
  * @return  $this
  */
 public function setBreaker(CircuitBreaker $breaker)
 {
     $this->instances[$breaker->getName()] = $breaker;
     return $this;
 }
 public function testEventsFireOpenToClosed()
 {
     $message = false;
     $c = new ArrayCache();
     $c->save('circuitbreaker_tests', ['failures' => [time() - 10]]);
     $b = new CircuitBreaker('tests', $c);
     $b->setThreshold(1);
     $b->onChange(function ($previous, $new) use(&$message) {
         $message = $previous . ' -> ' . $new;
     });
     $b->success();
     $this->assertEquals('open -> closed', $message);
 }