NAME
xDash::Archivist - Module for Archivist's client script implementation
SYNOPSIS
#!/usr/bin/perl
# xDash - Asynchronous Messaging and Instant Messaging reunited
#===
package EventLogger;
use base xDash::Logger::File;
# Check the correct file path for logger (absolute path if daemon!) and
# Uncomment 1.line and comment out 2.line below after debugging.
# sub Open { shift->SUPER::Open( 'home/xdash/archivist/event.log' ) }
sub Open { shift->SUPER::Open( STDOUT ) }
package ErrorLogger;
use base xDash::Logger::File;
# Check the correct file path for logger (absolute path if daemon!) and
# Uncomment 1.line and comment out 2.line below after debugging.
# sub Open { shift->SUPER::Open( 'home/xdash/archivist/error.log' ) }
sub Open { shift->SUPER::Open( STDERR ) }
package MessageLogger;
# Check the correct file path for logger (absolute path if daemon!) and
# Uncomment the 1.line and comment out 2.&3.line below after debugging.
# use base xDash::Logger::Dumb;
use base xDash::Logger::File;
sub Open { shift->SUPER::Open( STDOUT ) }
package EmergencyLogger;
# Check the correct file path for logger (absolute path if daemon!).
use base xDash::Logger::File;
sub Open { shift->SUPER::Open( 'home/xdash/archivist/emergency.log' ) }
package Archive;
use base xDash::Archive::Pg;
# Set up your own database access parameters
sub SetParameters { shift->SUPER::SetDatabaseConnection(
name => 'xdash', user => '', password => '' ) }
#===
package main;
use strict;
use warnings;
use xDash::Archivist;
my $archivist = new xDash::Archivist;
# After debugging change:
# daemon => 1, for running as daemon (daemon => O, console usage)
# delay => 10, for waiting 10 seconds before becomming a daemon
# timeout => 100, for waiting 100 seconds to try to reconnect
# Test settings:
$archivist->SetMode( daemon=> 0, delay=> 0, timeout=> 5 );
# Parameters from archivist.xml and default connection parameters
# from package Net::Jabber::Client (::Connect()) can be overriden here:
# hostname => string, port => integer,
# connectiontype => tcpip|http, ssl => 0|1
# Uncomment if needed, method is optional.
# $archivist->SetConnectionParameters( ... => ... , );
# Initiate Archivist's JID (absolute path if daemon!)
$archivist->SetParticipants( 'home/xdash/archivist/archivist.xml' );
# A comma separated list of archive error numbers on which Archivist's script
# dies and is restarted by the operating system.
$archivist->SetRestartArchiveError( -1 );
# Go on ...
$archivist->Process();
DESCRIPTION
USAGE
For detailed description, how xDash framework works, please refer to http://xdash.jabberstudio.org.
A convenient way for using the module and auto generating Archivist's script is the utility xdscr from deployment directory. For script usage read the deployment/README.txt or usage information embedded into the script. The synopsis above is an example of the Archivist's client script generated by the xdscr. You can find an introduction to the deployment: Planning and deploying xDash in a sandbox at http://xdash.jabberstudio.org/deployment/perl.
The module is developed in the object orientated way. You have to provide base classes for logging tasks and archive, which have to implement a fixed set of methods (driver pattern). You can use for logging xDash::Logger::File
and xDash::Logger::Dumb
in a way as it is proposed in the script generated by xdscr or provide your own implementation of the base class for EventLogger
, ErrorLogger
, MessageLogger
and EmergencyLogger
. You can use for archive xDash::Archive::Pg
as it is proposed in the script generated by xdscr. If you wish something else then PostgreSQL based persistence, you have to provide for the class Archive
your own implementation of the base class with all other belongings. If you have to develop your own logger or archive, see provided modules source code for further implementation hints. If you think, they can be reused, make them public over CPAN in the xDash::Spool and xDash::Archive namespace!
METHODS
- SetMode( daemon=> 0|1, delay=> $time, timeout=> $time, wait => $time )
-
daemon => 1, for running script as daemon; daemon => 0, console usage of the script; delay=> $time, for waiting $time seconds before becomming a daemon; timeout => $time, for waiting $time seconds to try to reconnect.
- SetConnectionParameters( hostname => $string, port => $integer, connectiontype => tcpip|http, ssl => 0|1 )
-
Overrides parameters <hostname> and <port> from the XML configuration file (usually archivist.xml) and default connection parameters from package Net::Jabber::Client (::Connect()). Method is optional.
- SetParticipants( $XML_configuration_file )
-
Initiate Sender's and Archivist's JIDs with a absolute path to the XML configuration file, usually with the name archivist.xml.
- SetRestartArchiveError( $error_number_1, $error_number_2, ... )
-
Sets a comma separated list of spool error numbers, on which the Archivist's script dies and is restarted by the operating system.
- Process( )
-
Go on...
BUGS
Any suggestions for improvement are welcomed!
If a bug is detected or nonconforming behavior, please send an error report to <jwach@cpan.org>. Please attache log entries, if possible.
COPYRIGHT
Copyright 2005 Jerzy Wachowiak <jwach@cpan.org>
This library is free software; you can redistribute it and/or modify it under the terms of the Apache 2.0 license attached to the module.