reverse_client_task.php 803 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. $gmc= new GearmanClient();
  3. $gmc->addServer();
  4. $gmc->setCreatedCallback("reverse_created");
  5. $gmc->setStatusCallback("reverse_status");
  6. $gmc->setCompleteCallback("reverse_complete");
  7. $gmc->setFailCallback("reverse_fail");
  8. $task= $gmc->addTask("reverse", "this is a test", NULL);
  9. if (! $gmc->runTasks())
  10. {
  11. echo "ERROR " . $gmc->error() . "\n";
  12. exit;
  13. }
  14. echo "DONE\n";
  15. function reverse_created($task)
  16. {
  17. echo "CREATED: " . $task->jobHandle() . "\n";
  18. }
  19. function reverse_status($task)
  20. {
  21. echo "STATUS: " . $task->jobHandle() . " - " . $task->taskNumerator() .
  22. "/" . $task->taskDenominator() . "\n";
  23. }
  24. function reverse_complete($task)
  25. {
  26. echo "COMPLETE: " . $task->jobHandle() . "\n";
  27. }
  28. function reverse_fail($task)
  29. {
  30. echo "FAILED: " . $task->jobHandle() . "\n";
  31. }
  32. ?>