libzookeeper icon indicating copy to clipboard operation
libzookeeper copied to clipboard

Async Zookeeper OPs

Open Timandes opened this issue 8 years ago • 0 comments

<?php
$base = new \EventBase();
$zc = new \ZookeeperClient();

$ev = new \Event($base, $zc->getFd(), \Event::READ, function($fd, $what, $arg = NULL) {
    $zc = $arg;

    $eventType = $zc->reapEventType();
    switch ($eventType) {
        case \ZookeeperClient::EVENT_CONNECTED:
            $zc->asyncGet('/zookeeper');
            break;
        case \ZookeeperClient::EVENT_GOT:
            $value = $zc->reapAsyncGet();
            var_dump($value);
            break;
    }
}, $zc);
$ev->add();

$zc->asyncConnect('localhost:2181');

$base->dispatch();

Timandes avatar Jul 02 '16 14:07 Timandes