Skip to content

Commit

Permalink
Improve transition from open to half open
Browse files Browse the repository at this point in the history
  • Loading branch information
stfndamjanovic committed Jan 27, 2024
1 parent 99903ae commit b1e65c8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/StateHandlers/OpenStateHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,24 @@ public function beforeCall(\Closure $action, ...$args)

throw CircuitOpenException::make($this->breaker->getName());
}

/**
* @return void
*/
public function onSucess()
{
$this->breaker->getStorage()->incrementSuccess();
}

/**
* @param \Exception $exception
* @return void
* @throws CircuitOpenException
*/
public function onFailure(\Exception $exception)
{
$this->breaker->openCircuit();

throw CircuitOpenException::make($this->breaker->getName());
}
}

0 comments on commit b1e65c8

Please sign in to comment.