NAME
ETLp::File::Watch - Waits for the appearance of a specific file or one or more files that match the supplied patterns
SYNOPSIS
A watcher will look for the existence of a file matching the supplied pattern (glob not regex) and then exits. Generally it signals that processing is required by the next item in the pipeline (which will generally want to use the file that matches that pattern).
Generally, detection of a file matching the pattern shouldn't be sufficient grounds for a watcher to exit. It should poll the file size at intervals to determine whether it is still growing. A watcher should only exit when the file size stops changing.
use ETLp::File::Watch;
my $watcher = ETLp::File::Watch->new(
directory => "$Bin/../incoming",
file_pattern => 'data*.zip',
duration => '5h'
);
unless ($watcher->watch() {
die "file not detected";
}
METHODS
new
Creates a new watcher
Parameters
A hashref containing:
* directory. Optional string. The location of the watch file
* file_pattern: Required string. The pattern (glob) that the watcher is
waiting for
* call: Required string. The config file and section to invoke when a file
is successfully found
* duration. Required. How long the watcher should wait before giving up. The
time can be specified by the duration (integer) followed by s, m, h or d -
(seconds, minutes, hours or days)
* wait_time. Optional integer. The time in seconds between each iteration of the
check. Defaults to 1
* raise_no_file_error. Optional boolean. If set to 1, an error will be raised if the
watcher expires without encountering a file. Deafults to 0.
* exit_on_detection. Optional boolean. If set to 1
Returns
* A file watcher
watch
Watches for the existence of a file pattern
Parameters
* None
Returns
* Void