Explicit reconnection attempt before each search.
[irspy-moved-to-github.git] / lib / ZOOM / IRSpy / Task / Search.pm
1 # $Id: Search.pm,v 1.9 2007-03-07 11:41:01 mike Exp $
2
3 package ZOOM::IRSpy::Task::Search;
4
5 use 5.008;
6 use strict;
7 use warnings;
8
9 use ZOOM::IRSpy::Task;
10 our @ISA = qw(ZOOM::IRSpy::Task);
11
12 =head1 NAME
13
14 ZOOM::IRSpy::Task::Search - a searching task for IRSpy
15
16 =head1 SYNOPSIS
17
18  ## to follow
19
20 =head1 DESCRIPTION
21
22  ## to follow
23
24 =cut
25
26 sub new {
27     my $class = shift();
28     my($query) = shift();
29
30     my $this = $class->SUPER::new(@_);
31     $this->{query} = $query;
32     $this->{rs} = undef;
33     return $this;
34 }
35
36 sub run {
37     my $this = shift();
38
39     $this->set_options();
40
41     my $conn = $this->conn();
42     ### Note that adding this next line DOES NOT HELP at the moment --
43     #   perhaps because of a ZOOM-C bug?
44     $conn->connect($conn->option("host"));
45
46     my $query = $this->{query};
47     $this->irspy()->log("irspy_task", $conn->option("host"),
48                         " searching for '$query'");
49     $this->{rs} = $conn->search_pqf($query);
50     warn "no ZOOM-C level events queued by $this"
51         if $conn->is_idle();
52
53     $this->set_options();
54 }
55
56 sub render {
57     my $this = shift();
58     return ref($this) . "(" . $this->{query} . ")";
59 }
60
61 use overload '""' => \&render;
62
63
64 =head1 SEE ALSO
65
66 ZOOM::IRSpy
67
68 =head1 AUTHOR
69
70 Mike Taylor, E<lt>mike@indexdata.comE<gt>
71
72 =head1 COPYRIGHT AND LICENSE
73
74 Copyright (C) 2006 by Index Data ApS.
75
76 This library is free software; you can redistribute it and/or modify
77 it under the same terms as Perl itself, either Perl version 5.8.7 or,
78 at your option, any later version of Perl 5 you may have available.
79
80 =cut
81
82 1;