1DBIAgent::Helper(3)   User Contributed Perl Documentation  DBIAgent::Helper(3)
2
3
4

NAME

6       POE::Component::DBIAgent::Helper - DBI Query Helper for DBIAgent
7

SYNOPSYS

9        use Socket qw/:crlf/;
10        use POE qw/Filter::Line Wheel::Run Component::DBIAgent::Helper/;
11
12        sub _start {
13            my $helper = POE::Wheel::Run ->new(
14                    Program     => sub {
15                        POE::Component::DBIAgent::Helper->run($self->{dsn},
16                                                              $self->{queries}
17                                                             );
18                    },
19                    StdoutEvent => 'db_reply',
20                    StderrEvent => 'remote_stderr',
21                    ErrorEvent  => 'error',
22                    StdinFilter => POE::Filter::Line->new(),
23                    StdoutFilter => POE::Filter::Line->new( Literal => CRLF),
24                    StderrFilter => POE::Filter::Line->new(),
25                   )
26             or carp "Can't create new DBIAgent::Helper: $!\n";
27
28        }
29
30        sub query {
31             my ($self, $query, $package, $state, @rest) = @_;
32
33             $self->{helper}->put(join '⎪', $query, $package, $state, @rest);
34        }
35
36        sub db_reply {
37           my ($kernel, $self, $heap, $input) = @_[KERNEL, OBJECT, HEAP, ARG0];
38
39           # $input is either the string 'EOF' or a Storable object.
40
41        }
42

DESCRIPTION

44       This is our helper routine for DBIAgent.  It accepts queries on STDIN,
45       and returns the results on STDOUT.  Queries are returned on a row-by-
46       row basis, followed by a row consisting of the string 'EOF'.
47
48       Each row is the return value of $sth->fetch, which is an arrayref.
49       This row is then passed to Storable for transport, and printed to STD‐
50       OUT.  HOWEVER, Storable uses newlines ("\n") in its serialized strings,
51       so the Helper is designed to use the "network newline" pair CR LF as
52       the line terminator for STDOUT.
53
54       When fetch() returns undef, one final row is returned to the calling
55       state: the string 'EOF'.  Sessions should test for this value FIRST
56       when being invoked with input from a query.
57
58       Initialization
59
60       The Helper has one public subroutine, called "run()", and is invoked
61       with two parameters:
62
63       The DSN
64           An arrayref of parameters to pass to DBI->connect (usually a dsn,
65           username, and password).
66
67       The Queries.
68           A hashref of the form Query_Name => "$SQL".  See POE::Compo‐
69           nent::DBIAgent for details.
70

BUGS

72       I have NO idea what to do about handling signals intelligently.
73       Specifically, under some circumstances, Oracle will refuse to acknowl‐
74       edge SIGTERM (presumably since its libraries are non-reentrant) so
75       sometimes SIGKILL is required to terminate a Helper process.
76

AUTHOR

78       This module has been fine-tuned and packaged by Rob Bloodgood
79       <robb@empire2.com>.  However, most of the code came directly from
80       Fletch <fletch@phydeaux.org>, either directly (Po:Co:DBIAgent:Queue) or
81       via his ideas.  Thank you, Fletch!
82
83       However, I own all of the bugs.
84
85       This module is free software; you may redistribute it and/or modify it
86       under the same terms as Perl itself.
87
88
89
90perl v5.8.8                       2004-09-17               DBIAgent::Helper(3)
Impressum