Qore FtpPoller Module Reference  1.0
FtpPoller Module

Introduction to the FtpPoller Module

The FtpPoller module implements an abstract class that will poll a remote directory with the FTP protocol and return matching files.

To use this class, subclass the FtpPoller class and implement the FtpPoller::FtpPoller::singleFileEvent() and FtpPoller::FtpPoller::postSingleFileEvent() methods.

FtpPoller Module Examples

The following simple example will poll for files and then print out information for the files polled (as well as all info, detail, and debug messages) and exit immediately:

%requires FtpPoller
class MyFtpPoller inherits FtpPoller {
constructor(FtpClient ftp_client, hash<auto> opts) : FtpPoller(ftp_client, opts) {
}
singleFileEvent(hash<FtpPollerFileEventInfo> file_info) {
printf("GOT FILE: %y\n", file_info);
# in this case, the polling stop operation will take effect after all the singleFileEvent() calls are made for the polling operation
stopNoWait();
}
postSingleFileEvent(hash<FtpPollerFileEventInfo> file_info) {
}
}
code info = sub (string msg) { printf("INFO: %s\n", msg); };
code detail = sub (string msg) { printf("DETAIL: %s\n", msg); };
code debug = sub (string msg) { printf("DEBUG: %s\n", msg); };
hash<auto> opts = {
"path": "/tmp"
"log_info": info,
"log_detail": detail,
"log_debug": debug,
};
FtpClient ftp_client("ftp://user@pass:localhost");
FtpPoller poller(ftp_client, opts);
poller.waitStop();
string printf(string fmt,...)
main FtpPoller namespace

Note that FtpPoller::stopNoWait() was called in the event thread because calling FtpPoller::stop() in the event thread would cause an exception to be thrown.

A useful poller class would implement the FtpPoller::singleFileEvent() method which process already-transferred files and the FtpPoller::postSingleFileEvent() by deleting / moving / renaming the files so that they would not be acquired on the next poll.

FtpPoller Module in Sandboxed Programs

The FtpPoller class includes support for running in sandboxed Program objects with the following parse options set:

FtpPoller Module Release Notes

Version 1.0

  • initial release