Gearman::Task(3pm)
π Gearman::Task π
okay bestie, welcome to Gearman::Task β it's part of the Perl docs, section 3pm, and it's literally just: a task in Gearman, from the point of view of a client. that's the whole vibe. β¨
πΈ NAME πΈ
Gearman::Task β a task in Gearman, from the point of view of a client. no cap, that's the name, that's the job. π
β¨ SYNOPSIS β¨
my $task = Gearman::Task->new("add", "1+2", {
...
});
$taskset->add_task($task);
$client->do_task($task);
$client->dispatch_background($task);
π¦ DESCRIPTION π¦
Gearman::Task is a Gearman::Client's representation of a task to be done. that's it. that's the girl. she's a task, she's got a client, she's ready. π
π USAGE π
π Gearman::Task->new($func, $arg, \%options)
Creates a new Gearman::Task object, and returns the object. main character moment fr fr. π
$func is the function name to be run. (yes, that you have a worker registered to process β that part is on you, bestie.)
$arg is an opaque scalar or scalarref representing the argument(s) to pass to the distributed function. wanna pass multiple arguments? you gotta encode them somehow into this one. that's up to you and your worker. lowkey chaotic but that's the deal. π
%options can contain:
uniqβ a key which indicates to the server that other tasks with the same function name and key will be merged into one. that is, the task will be run just once, but all the listeners waiting on that job will get the response multiplexed back to them.
uniq may also contain the magic value "-" (a single hyphen) which means the uniq key is the contents of the args. iconic shortcut behavior tbh. β¨
on_completeβ a subroutine reference to be invoked when the task is completed. the subroutine will be passed a reference to the return value from the worker process. πon_failβ a subroutine reference to be invoked when the task fails (or fails for the last time, if retries were specified). the reason could be passed to this callback as an argument. this callback won't be called after a failure if more retries are still possible. πon_retryβ a subroutine reference to be invoked when the task fails, but is about to be retried.
is passed one argument, what retry attempt number this is. (starts with 1) π
on_statusβ a subroutine reference to be invoked if the task emits status updates. arguments passed to the subref are ($numerator,$denominator), where those are left up to the client and job to determine. πon_warningβ a subroutine reference to be invoked if the task emits status updates. arguments passed to the subref are ($numerator,$denominator), where those are left up to the client and job to determine.
okay so real talk: the manpage literally describeson_warningwith the exact same words ason_status. not me making that up, that's just what it says. π
retry_countβ number of times job will be retried if there are failures. defaults to0.high_priorityβ the optionhigh_priorityis deprecated. use"priority => high"instead. boolean, whether this job should take priority over other jobs already enqueued.priorityβ valid value:highnormal(defaul β yes the manpage says "defaul", we're keeping her, she's part of the lore π )low
timeoutβ automatically fail, calling youron_failcallback, after this many seconds have elapsed without anon_failoron_completebeing called. defaults to0, which means never. bypasses anyretry_countremaining. β°try_timeoutβ automatically fail, calling youron_retrycallback (oron_failif out of retries), after this many seconds have elapsed. defaults to0, which means never. β³
and that's the whole page bestie, go forth and dispatch some tasks π«Ά
this was perl v5.26.2, dated 2018-08-30 β the source is User Contributed Perl Documentation, and the page is Gearman::Task(3pm). slay, bye! πβ¨π
π¦ where this page comes from
- debian bookworm: libgearman-client-perl 2.004.015-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libgearman-client-perl 2.004.015-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libgearman-client-perl 2.004.015-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libgearman-client-perl 2.004.015-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libgearman-client-perl 2.004.015-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms