| author | Vincent Tondellier <tonton+hg@team1664.org> |
| Sun, 03 Aug 2014 16:45:34 +0200 | |
| changeset 27 | 2b158020f0d5 |
| parent 23 | e621317229f7 |
| child 34 | e0d6597078a5 |
| permissions | -rw-r--r-- |
|
18
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
1 |
# This program is free software: you can redistribute it and/or modify |
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
2 |
# it under the terms of the GNU General Public License as published by |
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
3 |
# the Free Software Foundation, either version 3 of the License, or |
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
4 |
# (at your option) any later version. |
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
5 |
# |
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
6 |
# This program is distributed in the hope that it will be useful, |
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
7 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
8 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
9 |
# GNU General Public License for more details. |
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
10 |
# |
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
11 |
# You should have received a copy of the GNU General Public License |
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
12 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
13 |
|
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
14 |
package CrashTest::Decode::Queue::Gearman; |
|
27
2b158020f0d5
Revert to the non-async gearman client.
Vincent Tondellier <tonton+hg@team1664.org>
parents:
23
diff
changeset
|
15 |
use Mojo::Base -strict; |
|
2b158020f0d5
Revert to the non-async gearman client.
Vincent Tondellier <tonton+hg@team1664.org>
parents:
23
diff
changeset
|
16 |
use Gearman::Client; |
|
18
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
17 |
|
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
18 |
sub new {
|
|
19
300b902b5461
Reorganize config
Vincent Tondellier <tonton+hg@team1664.org>
parents:
18
diff
changeset
|
19 |
my ($class, $config, $dumperconfig, $storage) = @_; |
|
18
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
20 |
my $self = {};
|
|
27
2b158020f0d5
Revert to the non-async gearman client.
Vincent Tondellier <tonton+hg@team1664.org>
parents:
23
diff
changeset
|
21 |
$self->{gearman} = Gearman::Client->new(job_servers => $config->{GearmanServers});
|
|
18
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
22 |
bless ($self, $class); |
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
23 |
return $self; |
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
24 |
} |
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
25 |
|
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
26 |
sub decode {
|
| 23 | 27 |
my ($self, $file, $paramshash, $uuidstr, $cb) = @_; |
|
18
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
28 |
|
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
29 |
my $json = Mojo::JSON->new; |
|
19
300b902b5461
Reorganize config
Vincent Tondellier <tonton+hg@team1664.org>
parents:
18
diff
changeset
|
30 |
my $args = $json->encode({ file => $file->slurp, params => $paramshash, uuid => $uuidstr });
|
|
27
2b158020f0d5
Revert to the non-async gearman client.
Vincent Tondellier <tonton+hg@team1664.org>
parents:
23
diff
changeset
|
31 |
$self->{gearman}->dispatch_background('dump_decode', $args);
|
|
2b158020f0d5
Revert to the non-async gearman client.
Vincent Tondellier <tonton+hg@team1664.org>
parents:
23
diff
changeset
|
32 |
|
|
2b158020f0d5
Revert to the non-async gearman client.
Vincent Tondellier <tonton+hg@team1664.org>
parents:
23
diff
changeset
|
33 |
&$cb({ status => "backgrounded" });
|
|
18
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
34 |
} |
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
35 |
|
|
60db1090095b
Add Gearman decode worker
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
36 |
1; |