1Gearman::Task(3) User Contributed Perl Documentation Gearman::Task(3)
2
3
4
6 Gearman::Task - a task in Gearman, from the point of view of a client
7
9 my $task = Gearman::Task->new("add", "1+2", {
10 ...
11 });
12
13 $taskset->add_task($task);
14 $client->do_task($task);
15 $client->dispatch_background($task);
16
18 Gearman::Task is a Gearman::Client's representation of a task to be
19 done.
20
22 Gearman::Task->new($func, $arg, \%options)
23 Creates a new Gearman::Task object, and returns the object.
24
25 $func is the function name to be run. (that you have a worker
26 registered to process)
27
28 $arg is an opaque scalar or scalarref representing the argument(s) to
29 pass to the distributed function. If you want to pass multiple
30 arguments, you must encode them somehow into this one. That's up to
31 you and your worker.
32
33 %options can contain:
34
35 • uniq
36
37 A key which indicates to the server that other tasks with the same
38 function name and key will be merged into one. That is, the task
39 will be run just once, but all the listeners waiting on that job
40 will get the response multiplexed back to them.
41
42 Uniq may also contain the magic value "-" (a single hyphen) which
43 means the uniq key is the contents of the args.
44
45 • on_complete
46
47 A subroutine reference to be invoked when the task is completed.
48 The subroutine will be passed a reference to the return value from
49 the worker process.
50
51 • on_fail
52
53 A subroutine reference to be invoked when the task fails (or fails
54 for the last time, if retries were specified). The reason could be
55 passed to this callback as an argument. This callback won't be
56 called after a failure if more retries are still possible.
57
58 • on_retry
59
60 A subroutine reference to be invoked when the task fails, but is
61 about to be retried.
62
63 Is passed one argument, what retry attempt number this is. (starts
64 with 1)
65
66 • on_status
67
68 A subroutine reference to be invoked if the task emits status
69 updates. Arguments passed to the subref are ($numerator,
70 $denominator), where those are left up to the client and job to
71 determine.
72
73 • on_warning
74
75 A subroutine reference to be invoked if the task emits status
76 updates. Arguments passed to the subref are ($numerator,
77 $denominator), where those are left up to the client and job to
78 determine.
79
80 • retry_count
81
82 Number of times job will be retried if there are failures.
83 Defaults to 0.
84
85 • high_priority
86
87 the option high_priority is deprecated. Use "priority => high"
88 instead. Boolean, whether this job should take priority over other
89 jobs already enqueued.
90
91 • priority
92
93 valid value:
94
95 • high
96
97 • normal (defaul)
98
99 • low
100
101 • timeout
102
103 Automatically fail, calling your on_fail callback, after this many
104 seconds have elapsed without an on_fail or on_complete being
105 called. Defaults to 0, which means never. Bypasses any retry_count
106 remaining.
107
108 • try_timeout
109
110 Automatically fail, calling your on_retry callback (or on_fail if
111 out of retries), after this many seconds have elapsed. Defaults to
112 0, which means never.
113
114
115
116perl v5.34.0 2021-07-22 Gearman::Task(3)