Ejemplo n.º 1
0
 /**
  * Marks a successful request
  *
  * @link http://goo.gl/dtHN34
  * @return void
  */
 public function markSuccess()
 {
     if ($this->stateStorage->isCircuitOpen($this->commandKey)) {
         $this->stateStorage->closeCircuit($this->commandKey);
         // may cause some stats to be removed from reporting, see http://goo.gl/dtHN34
         $this->metrics->resetCounter();
     }
 }
Ejemplo n.º 2
0
 public function testGetHealthCountsExpiringSnapshot()
 {
     $now = \Odesk\Phystrix\microtime() * 1000;
     // current time in milliseconds
     // a snapshot created two seconds ago is no longer valid and we expect a new one
     $snapshot = new HealthCountsSnapshot($now - 2000, 11, 22);
     // setting it as the last snapshot into metrics
     $reflection = new \ReflectionClass('Odesk\\Phystrix\\CommandMetrics');
     $property = $reflection->getProperty('lastSnapshot');
     $property->setAccessible(true);
     $property->setValue($this->metrics, $snapshot);
     $this->counter->expects($this->exactly(2))->method('get')->will($this->returnValueMap(array(array(MetricsCounter::FAILURE, 22), array(MetricsCounter::SUCCESS, 33))));
     $newSnapshot = $this->metrics->getHealthCounts();
     $this->assertNotEquals($snapshot, $newSnapshot);
     $this->assertEquals(33, $newSnapshot->getSuccessful());
 }