FsEventPoller Module Introduction
Module FsEventPoller provides a high level API for event-driven file and directory monitors.
Available classes:
- FsEventPoller::AbstractFsEventPoller providing ad-hoc events whenever file is changed
- FsEventPoller::AbstractDelayedFsEventPoller providing delayed events of file changes to implement an event source with a configurable delay based on files' last modification times to provide file events for non-atomic file creation
Constructor Option Hashes
Event options are provided to the above classes with the following option hashes:
- AbstractFsEventPollerOptionInfo for the AbstractFsEventPoller class
- FsDelayedEventPollerOptionInfo for the AbstractDelayedFsEventPoller class
Example
%new-style
%require-types
%strict-args
%enable-all-warnings
%requires FsEventPoller
class MyFileEventSource inherits AbstractFsEventPoller {
constructor(string root, *hash<AbstractFsEventPollerOptionInfo> opts) : AbstractFsEventPoller(root, opts) {
}
fileEvent(hash<FsEventInfo> event) {
printf("event: %y\n", event);
}
}
MyFileEventSource events("/");
Counter stop(1);
set_signal_handler(SIGINT, sub () { print("stopping\n"); stop.dec(); });
stop.waitForZero();
File Name Masks and Matching
Any AbstractFsEventPoller can be configured to match file names by:
- A Qore regex-based mask (ex:
"inventory_[A-J].*\.csv"); Qore regex options can be provided in the reopts option key
- A glob-style mask (ex:
"*.csv")
User can specify one style of mask in the constructor. A FILEPOLLER-ERROR exception is raised whenever both masks are defined.
Default value for matching is to take all file names.
FsEventPoller Module Release Notes
FsEventPoller v0.2.0
- Added pause/resume capability to AbstractDelayedFsEventPoller
- Added path filtering options (include_paths, exclude_paths)
- Added error_callback option for async error handling
- Added event metadata (size, mtime, fullpath)
- Added batch event processing option
- Fixed minage error message
FsEventPoller v0.1.0