phpday 2027 - Call for Papers

GearmanClient::setWorkloadCallback

(PECL gearman >= 0.5.0)

GearmanClient::setWorkloadCallback — Set a callback for accepting incremental data updates

Descrizione

public function GearmanClient::setWorkloadCallback(callable $callback): bool

Sets a callback function to be called when a worker needs to send back data prior to job completion. A worker can do this when it needs to send updates, send partial results, or flush data during long running jobs.

Nota:

La callback verrà attivata solo per i task aggiunti (ad es. chiamando GearmanClient::addTask()) dopo la chiamata a questo metodo.

Elenco dei parametri

callback

Una funzione o un metodo da chiamare. Dovrebbe restituire un valore di ritorno Gearman valido.

Se non è presente alcuna istruzione return, il valore predefinito è GEARMAN_SUCCESS.

function callback(GearmanTask $task, mixed $context): int
task

Il task per cui viene chiamata questa callback.

context

Qualsiasi valore sia stato passato a GearmanClient::addTask() (o a un metodo equivalente) come context.

Valori restituiti

Restituisce true in caso di successo o false in caso di fallimento.

Vedere anche:

+add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top