App::MonM::Notifier::Store - monotifier store class
Version 1.02
use App::MonM::Notifier::Store; my $store = App::MonM::Notifier::Store->new( dsn => "DBI:mysql:database=monotifier;host=mysql.example.com", user => "username", password => "password", set => [ "RaiseError 0", "PrintError 0", "mysql_enable_utf8 1", ], expires => 3600*24*7, maxtime => 300, ); die($store->error) if $store->error;
DBI interface for monotifier store. This module provides store methods
my $store = App::MonM::Notifier::Store->new( dsn => "DBI:mysql:database=monotifier;host=mysql.example.com", user => "username", password => "password", set => [ "RaiseError 0", "PrintError 0", "mysql_enable_utf8 1", ], expires => 3600*24*7, maxtime => 300, );
Creates DBI object
Time in seconds of life of database record
Max time in seconds to sending one message
my $st = $store->cleanup;
Removes permanently queue entities based on how old they are
my $st = $store->dequeue( id => 1, );
Dequeues the element by setting success status (STATUS_SENT)
$store->delById($id) or die($store->error);
Delete record by id
my $dsn = $store->dsn;
Returns DSN string of current database connection
$store->enqueue( to => $user, channel => $ch_name, subject => $subject, message => $message, attributes => $ch, # Channel attributes ) or die($store->error);
Adds a new element at the end of the current queue and returns queue element ID
my $error = $store->error;
Returns error message
my $error = $store->error( "Error message" );
Sets error message if argument is provided.
my %data = $store->getById($id);
Returns data from database by id
my @table = $store->getAll(); my @table_100 = $store->getAll(100);
Returns data from database with limit supporting
print $store->is_sqlite ? "Is SQLite" : "Is not SQLite"
Returns true if type of current database is SQLite
$store->ping ? 'OK' : 'Database session is expired';
Checks the connection to database
my $st = $store->requeue( id => 1, code => 2, error => "My Error", );
Requeue entities that have been retrieved for processing early; sets status to STATUS_FAIL
my $entity = $store->retrieve(STATUS_FAIL);
Retrieves the next entity from the queue and returns it as hashref or undef if no entity
my $serializer = $store->serializer;
Returns serializer object
$store->purge or die($store->error);
Delete all records
CREATE TABLE IF NOT EXISTS monotifier ( `id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, `to` CHAR(255), -- Recipient name `channel` CHAR(255), -- Recipient channel `subject` TEXT, -- Message subject `message` TEXT, -- Message content (BASE64) `attributes` TEXT, -- Message attributes (JSON) `published` BIGINT(20), -- The publication time (unixtime) `scheduled` BIGINT(20), -- The scheduled time (unixtime) `expired` BIGINT(20), -- The expiration time (unixtime) `sent` BIGINT(20), -- The send time `attempt` INTEGER DEFAULT 0, -- Count of failed attempts `status` CHAR(32), -- Status of transaction `errcode` INT(11), -- Error code `errmsg` TEXT -- Error message )
0 -- No errors found 1 -- Error of the notifier level (notify method) 2 -- Error of the notifier level (remind method) 255 -- Error of the cleanup level
CTK::DBI, App::MonM
Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>
Copyright (C) 1998-2022 D&D Corporation. All Rights Reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See LICENSE file and https://dev.perl.org/licenses/
LICENSE
To install App::MonM::Notifier, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::MonM::Notifier
CPAN shell
perl -MCPAN -e shell install App::MonM::Notifier
For more information on module installation, please visit the detailed CPAN module installation guide.