One shall note, that callback function MUST either return a valid Gearman status code, or return nothing (do not return).
I.e. these are valid complete callbacks:
<?php
function goodCallbackOne(GearmanTask $task)
{
print_r($task);
}
?>
<?php
function goodCallbackTwo(GearmanTask $task)
{
print_r($task);
return GEARMAN_SUCCESS;
}
?>
While following is NOT, unless you want your client code to fail with Gearman error 'german wait:no active file descriptors':
<?php
function badCallbackTwo(GearmanTask $task)
{
print_r($task);
return true;
}
?>
GearmanClient::setCompleteCallback
(PECL gearman >= 0.5.0)
GearmanClient::setCompleteCallback — Définit une fonction à appeler une fois la tâche terminée
Description
Définit une fonction à appeler lorsqu'une tâche se termine. La fonction de rappel doit accepter un seul argument, un objet GearmanTask.
Liste de paramètres
-
callback -
Une fonction à appeler.
Valeurs de retour
Cette fonction retourne TRUE en cas de
succès ou FALSE si une erreur survient.
Voir aussi
- GearmanClient::setDataCallback() - Définit une fonction de rappel à appeler lorsqu'un paquet de données est reçu pour une tâche
- GearmanClient::setCreatedCallback() - Définit une fonction de rappel à appeler lorsqu'une tâche est placée dans la file d'attente
- GearmanClient::setExceptionCallback() - Définit une fonction de rappel pour les exceptions émises par l'agent
- GearmanClient::setFailCallback() - Définit une fonction de rappel à appeler lorsqu'un travail échoue
- GearmanClient::setStatusCallback() - Définit une fonction de rappel pour collecter les statuts d'une tâche
- GearmanClient::setWarningCallback() - Définit une fonction de rappel lors de l'émission d'alerte depuis l'agent
- GearmanClient::setWorkloadCallback() - Définit une fonction de rappel lors de la réception de mises à jour de données incrémentales
Justas Butkus ¶
1 year ago
