Changeset 1406
- Timestamp:
- 02/23/08 01:33:03 (5 months ago)
- Files:
-
- branches/release-30/extlib/TheSchwartz.pm (modified) (8 diffs)
- branches/release-30/extlib/TheSchwartz/FuncMap.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/release-30/extlib/TheSchwartz.pm
r1104 r1406 3 3 package TheSchwartz; 4 4 use strict; 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 scoreboard );6 7 our $VERSION = "1.0 6";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 scoreboard prioritize ); 6 7 our $VERSION = "1.07"; 8 8 9 9 use Carp qw( croak ); … … 36 36 37 37 $client->{retry_seconds} = delete $args{retry_seconds} || RETRY_DEFAULT; 38 $client->set_prioritize(delete $args{prioritize}); 38 39 $client->set_verbose(delete $args{verbose}); 39 40 $client->set_scoreboard(delete $args{scoreboard}); … … 167 168 funcid => $funcid, 168 169 @options 169 }, { limit => $limit }); 170 }, { limit => $limit, 171 ( $client->prioritize ? ( sort => 'priority', 172 direction => 'descend' ) : () ) 173 }); 170 174 } else { 171 175 push @jobs, $driver->search('TheSchwartz::Job' => { 172 176 funcid => $funcid, 173 177 @options 174 }, { limit => $limit }); 178 }, { limit => $limit, 179 ( $client->prioritize ? ( sort => 'priority', 180 direction => 'descend' ) : () ) 181 } 182 ); 175 183 } 176 184 } … … 215 223 grabbed_until => \ "<= $unixtime", 216 224 coalesce => { op => $op, value => $coval }, 217 }, { limit => $FIND_JOB_BATCH_SIZE }); 225 }, { limit => $FIND_JOB_BATCH_SIZE, 226 ( $client->prioritize ? ( sort => 'priority', 227 direction => 'descend' ) : () ) 228 } 229 ); 218 230 }; 219 231 if ($@) { … … 254 266 run_after => \ "<= $unixtime", 255 267 grabbed_until => \ "<= $unixtime", 256 }, { limit => $FIND_JOB_BATCH_SIZE }); 268 }, { limit => $FIND_JOB_BATCH_SIZE, 269 ( $client->prioritize ? ( sort => 'priority', 270 direction => 'descend' ) : () ) 271 } 272 ); 257 273 }; 258 274 if ($@) { … … 504 520 my $class = $job ? $job->funcname : undef; 505 521 if ($job) { 506 $job->debug("TheSchwartz::work_once got job of class '$class'"); 522 my $priority = $job->priority ? ", priority " . $job->priority : ""; 523 $job->debug("TheSchwartz::work_once got job of class '$class'$priority"); 507 524 } else { 508 525 $client->debug("TheSchwartz::work_once found no jobs"); … … 682 699 } 683 700 701 sub prioritize { 702 my TheSchwartz $client = shift; 703 return $client->{prioritize}; 704 } 705 706 sub set_prioritize { 707 my TheSchwartz $client = shift; 708 $client->{prioritize} = shift; 709 } 710 684 711 # current job being worked. so if something dies, work_safely knows which to mark as dead. 685 712 sub current_job { … … 806 833 messages will not be logged. 807 834 835 =item * C<prioritize> 836 837 A value indicating whether to utilize the job 'priority' field when selecting 838 jobs to be processed. If unspecified, jobs will always be executed in a 839 randomized order. 840 808 841 =item * C<driver_cache_expiration> 809 842 branches/release-30/extlib/TheSchwartz/FuncMap.pm
r1098 r1406 17 17 my($driver, $funcname) = @_; 18 18 19 ## Attempt to select funcmap record by name. If successful, return 20 ## object, otherwise proceed with insertion and return. 21 my ($map) = $driver->search('TheSchwartz::FuncMap' => 22 { funcname => $funcname } 23 ); 24 return $map if $map; 25 19 26 ## Attempt to insert a new funcmap row. Since the funcname column is 20 27 ## UNIQUE, if the row already exists, an exception will be thrown. 21 my$map = $class->new;28 $map = $class->new; 22 29 $map->funcname($funcname); 23 30 eval { $driver->insert($map) };
