ZooKeeper zookeeper_dispatch
(PECL zookeeper >= 0.4.0)
zookeeper_dispatch — 보류 중인 작업에 대한 콜백 호출
설명
zookeeper_dispatch(): void
Zookeeper_dispatch() 함수는 Zookeeper::get() 또는 Zookeeper::exists()와 같은 작업에 의해 passwd 콜백을 호출합니다.
주의 버전 0.4.0부터 이 함수는 비동기 작업을 수행하기 위해 수동으로 호출되어야 합니다. 이를 자동으로 수행하려면 프로그램 시작 부분에 틱을 선언할 수도 있습니다.
PHP 7.1 이후에는 이 함수를 무시할 수 있습니다. 이 확장은 EG(vm_interrupt)를 사용하여 비동기 디스패치를 구현합니다.
매개변수
이 함수에는 매개변수가 없습니다.
반환 값
값이 반환되지 않습니다.
오류/예외
이 메서드는 콜백을 호출할 수 없을 때 PHP 경고를 내보냅니다.
Examples
예제 #1 zookeeper_dispatch() 예제
콜백을 수동으로 디스패치합니다.
<?php
$client = new Zookeeper();
$client->connect('localhost:2181');
$client->get('/zookeeper', function() {
echo "Callback was called".PHP_EOL;
});
while(true) {
sleep(1);
zookeeper_dispatch();
}
?>
예제 #2 zookeeper_dispatch() 예제
틱을 선언합니다.
<?php
declare(ticks=1);
$client = new Zookeeper();
$client->connect('localhost:2181');
$client->get('/zookeeper', function() {
echo "Callback was called".PHP_EOL;
});
while(true) {
sleep(1);
}
?>
기타
- Zookeeper::addAuth() - 애플리케이션 자격 증명 지정
- Zookeeper::connect() - zookeeper와의 통신을 위한 핸들 생성
- Zookeeper::__construct() - zookeeper와의 통신을 위한 핸들 생성
- Zookeeper::exists() - Zookeeper에서 노드의 존재를 동기적으로 확인
- Zookeeper::get() - 노드와 연결된 데이터를 동기적으로 가져옵니다.
- Zookeeper::getChildren() - 노드의 자식을 동기적으로 나열합니다.
- Zookeeper::setWatcher() - 감시자 함수 설정