library/Odesk/Phystrix/CircuitBreaker.php
public function isOpen()
    {
        if ($this->stateStorage->isCircuitOpen($this->commandKey)) {
            // if we're open we immediately return true and don't bother attempting to 'close' ourself
            // as that is left to allowSingleTest and a subsequent successful test to close
            return true;
        }

        $healthCounts = $this->metrics->getHealthCounts();
        if ($healthCounts->getTotal() < $this->config->get('circuitBreaker')->get('requestVolumeThreshold')) {
            // we are not past the minimum volume threshold for the statistical window
            // so we'll return false immediately and not calculate anything
            return false;
        }

        $allowedErrorPercentage = $this->config->get('circuitBreaker')->get('errorThresholdPercentage');
        if ($healthCounts->getErrorPercentage() < $allowedErrorPercentage) {
            return false;
        } else {
            $this->stateStorage->openCircuit(
                $this->commandKey,
                $this->config->get('circuitBreaker')->get('sleepWindowInMilliseconds')
            );
            return true;
        }
    }
public function isOpen()
    {
        if ($this->stateStorage->isCircuitOpen($this->commandKey)) {
            // if we're open we immediately return true and don't bother attempting to 'close' ourself
            // as that is left to allowSingleTest and a subsequent successful test to close
            return true;
        }

        $healthCounts = $this->metrics->getHealthCounts();
        if ($healthCounts->getTotal() < $this->config->get('circuitBreaker')->get('requestVolumeThreshold')) {
            // we are not past the minimum volume threshold for the statistical window
            // so we'll return false immediately and not calculate anything
            return false;
        }

        $allowedErrorPercentage = $this->config->get('circuitBreaker')->get('errorThresholdPercentage');
        if ($healthCounts->getErrorPercentage() < $allowedErrorPercentage) {
            return false;
        } else {
            $this->stateStorage->openCircuit(
                $this->commandKey,
                $this->config->get('circuitBreaker')->get('sleepWindowInMilliseconds')
            );
            return true;
        }
    }
public function isOpen ( ) { if ( $ this -> stateStorage -> isCircuitOpen ( $ this -> commandKey ) ) { // if we're open we immediately return true and don't bother attempting to 'close' ourself // as that is left to allowSingleTest and a subsequent successful test to close return true ; } $ healthCounts = $ this -> metrics -> getHealthCounts ( ) ; if ( $ healthCounts -> getTotal ( ) < $ this -> config -> get ( 'circuitBreaker' ) -> get ( 'requestVolumeThreshold' ) ) { // we are not past the minimum volume threshold for the statistical window // so we'll return false immediately and not calculate anything return false ; } $ allowedErrorPercentage = $ this -> config -> get ( 'circuitBreaker' ) -> get ( 'errorThresholdPercentage' ) ; if ( $ healthCounts -> getErrorPercentage ( ) < $ allowedErrorPercentage ) { return false ; } else { $ this -> stateStorage -> openCircuit ( $ this -> commandKey , $ this -> config -> get ( 'circuitBreaker' ) -> get ( 'sleepWindowInMilliseconds' ) ) ; return true ; } }
Whether the circuit is open

@return boolean
Whether the circuit is open