1Gearman::Task(3)      User Contributed Perl Documentation     Gearman::Task(3)
2
3
4

NAME

6       Gearman::Task - a task in Gearman, from the point of view of a client
7

SYNOPSIS

9           my $task = Gearman::Task->new("add", "1+2", {
10                   .....
11
12           };
13
14           $taskset->add_task($task);
15           $client->do_task($task);
16           $client->dispatch_background($task);
17

DESCRIPTION

19       Gearman::Task is a Gearman::Client's representation of a task to be
20       done.
21

USAGE

23   Gearman::Task->new($func, $arg, \%options)
24       Creates a new Gearman::Task object, and returns the object.
25
26       $func is the function name to be run.  (that you have a worker
27       registered to process)
28
29       $arg is an opaque scalar or scalarref representing the argument(s) to
30       pass to the distributed function.  If you want to pass multiple
31       arguments, you must encode them somehow into this one.  That's up to
32       you and your worker.
33
34       %options can contain:
35
36       ·   uniq
37
38           A key which indicates to the server that other tasks with the same
39           function name and key will be merged into one.  That is, the task
40           will be run just once, but all the listeners waiting on that job
41           will get the response multiplexed back to them.
42
43           Uniq may also contain the magic value "-" (a single hyphen) which
44           means the uniq key is the contents of the args.
45
46       ·   on_complete
47
48           A subroutine reference to be invoked when the task is completed.
49           The subroutine will be passed a reference to the return value from
50           the worker process.
51
52       ·   on_fail
53
54           A subroutine reference to be invoked when the task fails (or fails
55           for the last time, if retries were specified).  No arguments are
56           passed to this callback.  This callback won't be called after a
57           failure if more retries are still possible.
58
59       ·   on_retry
60
61           A subroutine reference to be invoked when the task fails, but is
62           about to be retried.
63
64           Is passed one argument, what retry attempt number this is.  (starts
65           with 1)
66
67       ·   on_status
68
69           A subroutine reference to be invoked if the task emits status
70           updates.  Arguments passed to the subref are ($numerator,
71           $denominator), where those are left up to the client and job to
72           determine.
73
74       ·   retry_count
75
76           Number of times job will be retried if there are failures.
77           Defaults to 0.
78
79       ·   high_priority
80
81           Boolean, whether this job should take priority over other jobs
82           already enqueued.
83
84       ·   timeout
85
86           Automatically fail, calling your on_fail callback, after this many
87           seconds have elapsed without an on_fail or on_complete being
88           called. Defaults to 0, which means never.  Bypasses any retry_count
89           remaining.
90
91       ·   try_timeout
92
93           Automatically fail, calling your on_retry callback (or on_fail if
94           out of retries), after this many seconds have elapsed. Defaults to
95           0, which means never.
96
97   $task->is_finished
98       Returns bool: whether or not task is totally done (on_failure or
99       on_complete callback has been called)
100
101
102
103perl v5.12.1                      2009-10-05                  Gearman::Task(3)
Impressum