PHP 8.3.4 Released!

GearmanClient::setCompleteCallback

(PECL gearman >= 0.5.0)

GearmanClient::setCompleteCallbackDéfinit une fonction à appeler une fois la tâche terminée

Description

public GearmanClient::setCompleteCallback(callable $function): bool

Définit une fonction à appeler lorsqu'une GearmanTask se termine, ou quand GearmanJob::sendComplete() est appelé par le worker (selon ce qui se passe en premier).

Cette fonction de rappel est exécuté uniquement lors de l'exécution d'une GearmanTask à l'aide de GearmanClient::runTasks(). Il n'est pas utilisé pour des travaux individuels.

Liste de paramètres

function

Une fonction à appeler.

Valeurs de retour

Cette fonction retourne true en cas de succès ou false si une erreur survient.

Voir aussi

add a note

User Contributed Notes 1 note

up
6
Justas Butkus
12 years ago
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;
}
?>
To Top