| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# Copyright 2007-2010 David Snopek <dsnopek@gmail.com> |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify |
|
5
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
|
6
|
|
|
|
|
|
|
# the Free Software Foundation, either version 2 of the License, or |
|
7
|
|
|
|
|
|
|
# (at your option) any later version. |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
|
10
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12
|
|
|
|
|
|
|
# GNU General Public License for more details. |
|
13
|
|
|
|
|
|
|
# |
|
14
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
|
15
|
|
|
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16
|
|
|
|
|
|
|
# |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package POE::Component::MessageQueue::Storage::DBI; |
|
19
|
11
|
|
|
11
|
|
1503
|
use Moose; |
|
|
11
|
|
|
|
|
28
|
|
|
|
11
|
|
|
|
|
82
|
|
|
20
|
|
|
|
|
|
|
extends qw(POE::Component::MessageQueue::Storage::Generic); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
has '+package' => ( |
|
23
|
|
|
|
|
|
|
default => 'POE::Component::MessageQueue::Storage::Generic::DBI', |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
around new => sub { |
|
27
|
|
|
|
|
|
|
my ($original, $class) = (shift, shift); |
|
28
|
|
|
|
|
|
|
my @args; |
|
29
|
|
|
|
|
|
|
if (ref($_[0]) eq 'HASH') { |
|
30
|
|
|
|
|
|
|
@args = %{$_[0]}; |
|
31
|
|
|
|
|
|
|
} else { |
|
32
|
|
|
|
|
|
|
@args = @_; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
$original->($class, @args, options => \@args); |
|
35
|
|
|
|
|
|
|
}; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub BUILD { |
|
38
|
7
|
|
|
7
|
0
|
2711
|
my ($self) = @_; |
|
39
|
|
|
|
|
|
|
# Forces early termination if we cannot connect to db. |
|
40
|
7
|
|
|
|
|
367
|
eval 'require ' . $self->package; |
|
41
|
7
|
|
|
|
|
348
|
$self->package->new(@{$self->options}); |
|
|
7
|
|
|
|
|
306
|
|
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=pod |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 NAME |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
POE::Component::MessageQueue::Storage::DBI -- A storage engine that uses L<DBI> |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
use POE; |
|
57
|
|
|
|
|
|
|
use POE::Component::MessageQueue; |
|
58
|
|
|
|
|
|
|
use POE::Component::MessageQueue::Storage::DBI; |
|
59
|
|
|
|
|
|
|
use strict; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# For mysql: |
|
62
|
|
|
|
|
|
|
my $DB_DSN = 'DBI:mysql:database=perl_mq'; |
|
63
|
|
|
|
|
|
|
my $DB_USERNAME = 'perl_mq'; |
|
64
|
|
|
|
|
|
|
my $DB_PASSWORD = 'perl_mq'; |
|
65
|
|
|
|
|
|
|
my $DB_OPTIONS = undef; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
POE::Component::MessageQueue->new({ |
|
68
|
|
|
|
|
|
|
storage => POE::Component::MessageQueue::Storage::DBI->new({ |
|
69
|
|
|
|
|
|
|
dsn => $DB_DSN, |
|
70
|
|
|
|
|
|
|
username => $DB_USERNAME, |
|
71
|
|
|
|
|
|
|
password => $DB_PASSWORD, |
|
72
|
|
|
|
|
|
|
options => $DB_OPTIONS |
|
73
|
|
|
|
|
|
|
}) |
|
74
|
|
|
|
|
|
|
}); |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
POE::Kernel->run(); |
|
77
|
|
|
|
|
|
|
exit; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
A storage engine that uses L<DBI>. All messages stored with this backend are |
|
82
|
|
|
|
|
|
|
persisted. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Performance is increased greatly by wrapping this engine in |
|
85
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Throttled> at the expense of being slower |
|
86
|
|
|
|
|
|
|
to persist messages. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This module is really just L<POE::Component::MessageQueue::Storage::Generic> with |
|
89
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Generic::DBI>. See the documentation for |
|
90
|
|
|
|
|
|
|
those modules for more information (primarily |
|
91
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Generic::DBI>). |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 CONSTRUCTOR PARAMETERS |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=over 2 |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item dsn => SCALAR |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item username => SCALAR |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item password => SCALAR |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item options => SCALAR |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item mq_id => SCALAR |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=back |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
L<POE::Component::MessageQueue>, |
|
112
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage>, |
|
113
|
|
|
|
|
|
|
L<DBI> |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
I<Other storage engines:> |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Memory>, |
|
118
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::BigMemory>, |
|
119
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::FileSystem>, |
|
120
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Generic>, |
|
121
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Generic::DBI>, |
|
122
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Throttled>, |
|
123
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Complex>, |
|
124
|
|
|
|
|
|
|
L<POE::Component::MessageQueue::Storage::Default> |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
|
127
|
|
|
|
|
|
|
|