Gearman GearmanClient::jobStatus

gearman_job_status

(PECL gearman >= 0.5.0)

GearmanClient::jobStatus -- gearman_job_status — 백그라운드 작업 상태 가져오기


설명

객체 지향 스타일(메소드):

public GearmanClient::jobStatus(string $job_handle): array

작업 핸들이 지정된 백그라운드 작업의 상태를 가져옵니다. 상태 정보는 작업이 알려진지 여부, 작업이 현재 실행 중인지 여부 및 완료율을 지정합니다.


매개변수

job_handle
Gearman 서버에서 할당한 작업 핸들

반환 값

제공된 작업 핸들에 해당하는 작업의 상태 정보를 포함하는 배열입니다. 첫 번째 배열 요소는 작업이 알려져 있는지 여부를 나타내는 부울이고, 두 번째 요소는 작업이 아직 실행 중인지 여부를 나타내는 부울이며, 세 번째 및 네 번째 요소는 각각 부분 완료율의 분자와 분모에 해당합니다.


Examples

예제 #1 장기 실행 백그라운드 작업의 상태 모니터링

                  
<?php

/* create our object */
$gmclient= new GearmanClient();

/* add the default server */
$gmclient->addServer();

/* run reverse client */
$job_handle = $gmclient->doBackground("reverse", "this is a test");

if ($gmclient->returnCode() != GEARMAN_SUCCESS)
{
  echo "bad return code\n";
  exit;
}

$done = false;
do
{
   sleep(3);
   $stat = $gmclient->jobStatus($job_handle);
   if (!$stat[0]) // the job is known so it is not done
      $done = true;
   echo "Running: " . ($stat[1] ? "true" : "false") . ", numerator: " . $stat[2] . ", denomintor: " . $stat[3] . "\n";
}
while(!$done);

echo "done!\n";

?>
                  
                

위의 예는 다음과 유사한 결과를 출력합니다.

Running: true, numerator: 3, denomintor: 14
Running: true, numerator: 6, denomintor: 14
Running: true, numerator: 9, denomintor: 14
Running: true, numerator: 12, denomintor: 14
Running: false, numerator: 0, denomintor: 0
done!
                

기타