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
50       STDOUT.  HOWEVER, Storable uses newlines ("\n") in its serialized
51       strings, so the Helper is designed to use the "network newline" pair CR
52       LF as 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       The Helper has one public subroutine, called run(), and is invoked with
60       two parameters:
61
62       The DSN
63           An arrayref of parameters to pass to DBI->connect (usually a dsn,
64           username, and password).
65
66       The Queries.
67           A hashref of the form Query_Name => "$SQL".  See
68           POE::Component::DBIAgent for details.
69

BUGS

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

AUTHOR

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