App-Basis-Queue
view release on metacpan or search on metacpan
bin/qpubsub view on Meta::CPAN
=head1 DESCRIPTION
Add am item to a queue or process an item from a queue
config file is in ~/.abq
abq:
queue:
dsn: dbi:SQLite:/tmp/abq.sqlite
user:
password:
The queue entry holds information about the queue database that you want to connect to, this is
obviously a perl DBI style connection
=cut
#
# (c) Kevin Mulholland, moodfarm@cpan.org
# this code is released under the Perl Artistic License
bin/qpubsub view on Meta::CPAN
$settings->{file} ||= get_program . "_$queue.tweets" ;
msg_exit( "Could not find valid config in $ENV{HOME}/.$program", 2 )
if ( !$queue || !$settings ) ;
# update the config if it needs it
$cfg->store() ;
my $q = $cfg->get("/abq/queue") ;
$q->{prefix} ||= "/" ;
my $theq = connect_queue( $q->{dsn}, $q->{user}, $q->{password},
$q->{prefix} . $queue ) ;
if ( !$theq ) {
msg_exit( "Could not connect to queue $q->{dsn}", 2 ) ;
}
# get the things out of the way that are information only
# if asking for size or peeking, then there is no message adding or sending
if ( $opt{size} || $opt{peek} ) {
my $s = $theq->queue_size() ;
bin/qsimple view on Meta::CPAN
=head1 DESCRIPTION
Add am item to a queue or process an item from a queue
config file is in ~/.abq
queue:
dsn: dbi:SQLite:/tmp/abq.sqlite
user:
password:
The queue entry holds information about the queue database that you want to connect to, this is
obviously a perl DBI style connection
=cut
#
# (c) Kevin Mulholland, moodfarm@cpan.org
# this code is released under the Perl Artistic License
bin/qsimple view on Meta::CPAN
my $q = $cfg->get("queue") ;
msg_exit( "Could not find valid config in " . QUEUE_CONFIG, 2 )
if ( !$q ) ;
$q->{prefix} ||= "/simple" ;
$q->{prefix} .= "/" if ( $opt{queue} !~ /^\// ) ;
$opt{queue} = $q->{prefix} . $opt{queue} ;
$opt{queue} =~ s|//|/|g ;
my $theq
= connect_queue( $q->{dsn}, $q->{user}, $q->{password}, $opt{queue} ) ;
msg_exit( "Could not connect to queue $q->{dsn}", 2 ) if ( !$theq ) ;
if ( $opt{pop} ) {
my $msg = $theq->pop() ;
print "$msg->{data}\n" if ($msg) ;
} elsif ($msg) {
my $id = $theq->push( data => { data => $msg } ) ;
msg_exit( "Could not push message", 1 ) if ( !$id ) ;
} else {
=head1 DESCRIPTION
Add am item to a queue or process an item from a queue
config file is in ~/.abq
queue:
dsn: dbi:SQLite:/tmp/abq.sqlite
user:
password:
The queue entry holds information about the queue database that you want to connect to, this is
obviously a perl DBI style connection
=cut
#
# (c) Kevin Mulholland, moodfarm@cpan.org
# this code is released under the Perl Artistic License
if ( !$q ) ;
my ( $activates, $epoch ) = parse_datetime( $opt{activates} ) ;
$q->{prefix} ||= "/task" ;
$q->{prefix} .= "/" if ( $opt{queue} !~ /^\// ) ;
$opt{queue} = $q->{prefix} . $opt{queue} ;
$opt{queue} =~ s|//|/|g ;
my $theq
= connect_queue( $q->{dsn}, $q->{user}, $q->{password}, $opt{queue} ) ;
msg_exit( "Could not connect to queue $q->{dsn}", 2 ) if ( !$theq ) ;
if ( !$theq ) {
msg_exit( "Could not connect to queue $q->{dsn}", 2 ) ;
}
# get the things out of the way that are information only
# if asking for size or peeking, then there is no message adding or sending
if ( $opt{size} || $opt{peek} ) {
( run in 0.753 second using v1.01-cache-2.11-cpan-49f99fa48dc )