Bravo3\Orm\Drivers\Redis\SentinelMonitor::validateConnection PHP Method

validateConnection() protected method

Function returns true if connection to redis host is accessible based on the output received from Sentinel.
protected validateConnection ( array $host_info ) : boolean
$host_info array
return boolean
    protected function validateConnection($host_info)
    {
        if ('master' === $host_info['role-reported']) {
            // Verify reported master is up based on parameters discovered
            // by sentinel
            $down_after_interval = (int) $host_info['down-after-milliseconds'];
            $last_ok_since = (int) $host_info['last-ok-ping-reply'];
            if ($last_ok_since > $down_after_interval) {
                return false;
            }
        } elseif ('slave' === $host_info['role-reported']) {
            // If slave status is disconnected ignore
            if (!(false === strpos($host_info['flags'], 'disconnected'))) {
                return false;
            }
            // If slave is subjectively down ignore
            // Reference: http://redis.io/topics/sentinel#pubsub-messages
            if (!(false === strpos($host_info['flags'], 's_down'))) {
                return false;
            }
            // If slave is objectively down ignore
            if (!(false === strpos($host_info['flags'], 'o_down'))) {
                return false;
            }
        }
        return true;
    }