299 |
debug => $debug, |
debug => $debug, |
300 |
}); |
}); |
301 |
|
|
|
sub iterate_over { |
|
|
my ( $what, $error ) = @_; |
|
|
my @result; |
|
|
if ( ref( $what ) eq 'ARRAY' ) { |
|
|
@result = @{ $what }; |
|
|
} elsif ($db_config->{input}) { |
|
|
@result = ( $what ); |
|
|
} else { |
|
|
$error->() if ref($error) eq 'CODE'; |
|
|
} |
|
|
return @result; |
|
|
} |
|
302 |
|
|
303 |
# |
# |
304 |
# prepare output |
# prepare output |
305 |
# |
# |
306 |
my @outputs = iterate_over( $db_config->{output}, sub { |
my @outputs = force_array( $db_config->{output}, sub { |
307 |
$log->error("Database $database doesn't have any outputs defined. Do you want to remove it from configuration?" ); |
$log->error("Database $database doesn't have any outputs defined. Do you want to remove it from configuration?" ); |
308 |
} ); |
} ); |
309 |
|
|
318 |
|
|
319 |
$log->debug("loading output module $module"); |
$log->debug("loading output module $module"); |
320 |
eval "require $module"; |
eval "require $module"; |
321 |
|
|
322 |
|
# add database to arugemnts for output filter |
323 |
$output->{database} = $database; |
$output->{database} = $database; |
324 |
|
|
325 |
$log->debug("calling $module->new(",dump( $output ),")"); |
$log->debug("calling $module->new(",dump( $output ),")"); |
335 |
# |
# |
336 |
|
|
337 |
|
|
338 |
my @inputs = iterate_over( $db_config->{input}, sub { |
my @inputs = force_array( $db_config->{input}, sub { |
339 |
$log->info("database $database doesn't have inputs defined"); |
$log->info("database $database doesn't have inputs defined"); |
340 |
} ); |
} ); |
341 |
|
|
509 |
} |
} |
510 |
|
|
511 |
|
|
512 |
|
# setup input name for all output filters |
513 |
|
foreach my $out ( @output_modules ) { |
514 |
|
if ( $out->can('input') ) { |
515 |
|
$out->input( $input_name ); |
516 |
|
} else { |
517 |
|
$log->warn("output filter $out doesn't support input name"); |
518 |
|
} |
519 |
|
} |
520 |
|
|
521 |
|
|
522 |
foreach my $pos ( 0 ... $input_db->size ) { |
foreach my $pos ( 0 ... $input_db->size ) { |
523 |
|
|
524 |
my $row = $input_db->fetch || next; |
my $row = $input_db->fetch || next; |