Changeset 156

Show
Ignore:
Timestamp:
02/09/09 21:46:10 (10 months ago)
Author:
swistow
Message:

Merge in trunk

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/use-existing-dbh/lib/TheSchwartz.pm

    r154 r156  
    833833appropriate jobs in the other databases automatically. 
    834834 
    835 Each member of the C<databases> value should be a hashref containing: 
     835Each member of the C<databases> value should be a hashref containing either: 
    836836 
    837837=over 4 
     
    848848 
    849849The password to use when connecting to this database. 
     850 
     851=back 
     852 
     853or 
     854 
     855=over 4 
     856 
     857=item * C<driver> 
     858 
     859A C<Data::ObjectDriver::Driver::DBI> object. 
     860 
     861See note below. 
    850862 
    851863=back 
     
    10141026Given an open driver I<$driver> to a database, gets the current server time from the database. 
    10151027 
     1028=head1 THE SCOREBOARD 
     1029 
     1030The scoreboards can be used to monitor what the TheSchwartz::Worker subclasses are 
     1031currently working on.  Once the scoreboard has been enabled in the workers with 
     1032C<set_scoreboard> method the C<thetop> utility (shipped with TheSchwartz distribuition 
     1033in the C<extras> directory) can be used to list all current jobs being worked on. 
     1034 
     1035=head2 C<< $client->set_scoreboard( $dir ) >> 
     1036 
     1037Enables the scoreboard.  Setting this to C<1> or C<on> will cause TheSchwartz to create 
     1038a scoreboard file in a location it determines is optimal. 
     1039 
     1040Passing in any other option sets the directory the TheSchwartz scoreboard directory should 
     1041be created in.  For example, if you set this to C</tmp> then this would create a directory 
     1042called C</tmp/theschwartz> and a scoreboard file C</tmp/theschwartz/scoreboard.pid> in it 
     1043(where pid is the current process pid.)  
     1044 
     1045=head2 C<< $client->scoreboard() >> 
     1046 
     1047Returns the path to the current scoreboard file. 
     1048 
     1049=head2 C<< $client->start_scoreboard() >> 
     1050 
     1051Writes the current job information to the scoreboard file (called by the worker 
     1052in work_safely before it actually starts working) 
     1053 
     1054=head2 C<< $client->end_scoreboard() >> 
     1055 
     1056Appends the current job duration to the end of the scoreboard file (called by 
     1057the worker in work_safely once work has been completed) 
     1058 
     1059=head2 C<< $client->clean_scoreboard() >> 
     1060 
     1061Removes the scoreboard file (but not the scoreboard directory.)  Automatically 
     1062called by TheSchwartz during object destruction (i.e. when the instance goes 
     1063out of scope) 
     1064 
     1065=head1 PASSING IN AN EXISTING DRIVER 
     1066 
     1067You can pass in a existing C<Data::Object::Driver::DBI> object which also allows you 
     1068to reuse exist Database handles like so: 
     1069 
     1070        my $dbh = DBI->connect( $dsn, "root", "", { 
     1071                RaiseError => 1, 
     1072                PrintError => 0, 
     1073                AutoCommit => 1, 
     1074            } ) or die $DBI::errstr; 
     1075        my $driver = Data::ObjectDriver::Driver::DBI->new( dbh => $dbh); 
     1076        return TheSchwartz->new(databases => [{ driver => $driver }]); 
     1077 
     1078B<Note>: it's important that the C<RaiseError> and C<AutoCommit> flags are  
     1079set on the handle for various bits of functionality to work. 
     1080 
     1081 
    10161082=head1 COPYRIGHT, LICENSE & WARRANTY 
    10171083