public function onRequestExecute(RequestEvent $event)
    {
        $request = $event->getRequest();

        //Make sure we have some nodes to choose from
        if (count($this->nodes) === 0) {
            throw new RuntimeException("No nodes in cluster, request failed");
        }

        //Choose a random node
        $request->node = $this->nodes[array_rand($this->nodes)];

    }
public function onRequestExecute(RequestEvent $event)
    {
        $request = $event->getRequest();

        //Make sure we have some nodes to choose from
        if (count($this->nodes) === 0) {
            throw new RuntimeException("No nodes in cluster, request failed");
        }

        //Choose a random node
        $request->node = $this->nodes[array_rand($this->nodes)];

    }
public function onRequestExecute ( RequestEvent $ event ) { $ request = $ event -> getRequest ( ) ; //Make sure we have some nodes to choose from if ( count ( $ this -> nodes ) === 0 ) { throw new RuntimeException ( "No nodes in cluster, request failed" ) ; } //Choose a random node $ request -> node = $ this -> nodes [ array_rand ( $ this -> nodes ) ] ; }
Triggered just prior to a request being executed
Inject a random node into the Request object

@param  RequestEvent                $event

@throws exceptions\RuntimeException
Triggered just prior to a request being executed Inject a random node into the Request object