Changeset 124
- Timestamp:
- 06/20/07 21:12:09 (1 year ago)
- Files:
-
- trunk/CHANGES (modified) (1 diff)
- trunk/lib/TheSchwartz.pm (modified) (6 diffs)
- trunk/t/api.t (modified) (2 diffs)
- trunk/t/server-time.t (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/CHANGES
r122 r124 1 1.05 2 3 - Set TheSchwartz::Job::insert_time to current server time when 4 inserting a new job. 5 1 6 1.04 (2007-05-22) 2 7 trunk/lib/TheSchwartz.pm
r122 r124 5 5 use fields qw( databases retry_seconds dead_dsns retry_at funcmap_cache verbose all_abilities current_abilities current_job cached_drivers driver_cache_expiration ); 6 6 7 our $VERSION = "1.0 4";7 our $VERSION = "1.05"; 8 8 9 9 use Carp qw( croak ); … … 269 269 } 270 270 271 sub get_server_time { 272 my TheSchwartz $client = shift; 273 my($driver) = @_; 274 my $unixtime_sql = $driver->dbd->sql_for_unixtime; 275 return $driver->rw_handle->selectrow_array("SELECT $unixtime_sql"); 276 } 277 271 278 sub _grab_a_job { 272 279 my TheSchwartz $client = shift; … … 287 294 my $old_grabbed_until = $job->grabbed_until; 288 295 289 my $unixtime_sql = $driver->dbd->sql_for_unixtime; 290 my $server_time = $driver->rw_handle->selectrow_array("SELECT $unixtime_sql") 296 my $server_time = $client->get_server_time($driver) 291 297 or die "expected a server time"; 292 298 … … 329 335 ## on the hashed DSN. Also: this might fail, if the database is dead. 330 336 $job->funcid( $client->funcname_to_id($driver, $hashdsn, $job->funcname) ); 337 338 my $time = $client->get_server_time($driver) 339 or die "Can't get server time"; 340 $job->insert_time($time); 331 341 332 342 ## Now, insert the job. This also might fail. … … 791 801 before looking again. 792 802 803 =head2 C<$client-E<gt>work_on($handle)> 804 805 Given a job handle (a scalar string) I<$handle>, runs the job, then returns. 806 793 807 =head2 C<$client-E<gt>find_job_for_workers( [$abilities] )> 794 808 … … 811 825 job databases. 812 826 827 =head2 C<$client-E<gt>get_server_time( $driver )> 828 829 Given an open driver I<$driver> to a database, gets the current server time from the database. 830 813 831 =head1 COPYRIGHT, LICENSE & WARRANTY 814 832 trunk/t/api.t
r122 r124 8 8 9 9 use TheSchwartz; 10 use Test::More tests => 8 0;10 use Test::More tests => 84; 11 11 12 run_tests(4 0, sub {12 run_tests(42, sub { 13 13 foreach my $pfx ("", "testprefix_") { 14 14 … … 31 31 isa_ok $job, 'TheSchwartz::Job'; 32 32 is $job->funcname, 'feedmajor', 'handle->job gives us the right job'; 33 cmp_ok $job->insert_time, '>', 0, 'insert_time is non-zero'; 33 34 34 35 # getting a handle object back
