private function getClient(): \GearmanClient
    {
        if (null === $this->client) {
            $client = new \GearmanClient();
            $client->setTimeout($this->timeout);

            if (empty($this->servers)) {
                try {
                    // by default we add the local machine
                    if (!$client->addServer()) {
                        throw new \GearmanException(
                            'GearmanClient::addServer returned false.',
                            GEARMAN_COULD_NOT_CONNECT
                        );
                    }
                } catch (\Throwable $e) {
                    throw new \GearmanException(
                        'Unable to add local server 127.0.0.1:4730.  ' . $e->getMessage(),
                        GEARMAN_COULD_NOT_CONNECT
                    );
                }
            } else {
                shuffle($this->servers);
                $added = 0;
                foreach ($this->servers as $server) {
                    $host = isset($server['host']) ? $server['host'] : '127.0.0.1';
                    $port = (int)isset($server['port']) ? $server['port'] : 4730;
                    try {
                        if ($client->addServer($host, $port)) {
                            $added++;
                        }
                    } catch (\Throwable $e) {
                        // do nothing, yet.
                    }
                }

                if (0 === $added) {
                    throw new \GearmanException(
                        sprintf('Unable to add any of these servers: %s', json_encode($this->servers)),
                        GEARMAN_COULD_NOT_CONNECT
                    );
                }
            }

            $this->client = $client;
        }

        return $this->client;
    }