Qore FilePoller Module Reference 2.0
Loading...
Searching...
No Matches
FilePoller.qm.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
2
3/* FilePoller.qm Copyright (C) 2014 - 2024 Qore Technologies s.r.o.
4
5 Permission is hereby granted, free of charge, to any person obtaining a
6 copy of this software and associated documentation files (the "Software"),
7 to deal in the Software without restriction, including without limitation
8 the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 and/or sell copies of the Software, and to permit persons to whom the
10 Software is furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 DEALINGS IN THE SOFTWARE.
22*/
23
24// make sure we have the required qore version
25
26
27
28
72namespace FilePoller {
74const AppName = "Filesystem";
75
77const EVENT_FILE = "file-event";
78
80public hashdecl FilePollerFileEventInfo {
82 int dev;
83
85 int inode;
86
88
90 int mode;
91
93 int nlink;
94
96 int uid;
97
99 int gid;
100
102 int rdev;
103
105 int size;
106
108 date atime;
109
111 date mtime;
112
114 date ctime;
115
117
120
122
125
127
138 string type;
139
141 string perm;
142
144 string name;
145
147 string filepath;
148
150 *string link;
151};
152
155
156public:
158 const OrderAsc = 0;
160 const OrderDesc = 1;
161
163 const SortNone = 0;
165 const SortName = 1;
167 const SortDate = 2;
168
170 const Options = ...;
171
172
174 const RequiredKeys = ...;
175
176
177protected:
179 string path;
180
182 string mask;
183
185 int poll_interval = 10;
186
188 bool runflag = False;
189
191 bool fatal = False;
192
194 int pollcnt = 0;
195
197 int sort_type = SortName;
198
200 int sort_order = OrderAsc;
201
204
206 int tid;
207
210
212 int reopt;
213
215 *softint minage;
216
218 *code log_info;
219
222
225
228
230 *code sleep;
231
232public:
233
235
267 constructor(string n_path, string n_mask, *hash<auto> n_opts);
268
269
272
273
275 setPath(string path);
276
277
279
284 list<hash<FilePollerFileEventInfo>> getFiles(int sort = FilePoller::SortNone, int order = FilePoller::OrderAsc);
285
286
288
291 int start();
292
293
295
305
306
308
313
314
316
326
327
329
333
334
336 bool runOnce();
337
338
340protected:
341 fileSleep(softint secs);
342public:
343
344
346protected:
348public:
349
350
352
354 fileEvent(list<hash<FilePollerFileEventInfo>> files);
355
356
358
381 abstract singleFileEvent(hash<FilePollerFileEventInfo> event);
382
384
388 static checkPath(string path, string type, bool write = False);
389
392
393
395protected:
396 logInfo(string fmt, ...);
397public:
398
399
401protected:
402 logDetail(string fmt, ...);
403public:
404
405
407protected:
408 logDebug(string fmt, ...);
409public:
410
411};
412
414
419
420public:
423
424
425protected:
427 EmbeddedFilePoller poller;
428
429public:
430
432 constructor(*hash<auto> options);
433
434
435 destructor();
436
437
438 string getName();
439
440
442 *string getDesc();
443
444
446
449 updateConnectionObjects(object conn, object connobj);
450
451
453
457protected:
458 hash<string, hash<DataProviderMessageInfo>> getEventTypesImpl();
459public:
460
461};
462
464
471
472public:
474 const ProviderInfo = ...;
475
476
478 constructor(*hash<auto> options) ;
479
480
481protected:
482 hash<DataProviderInfo> getStaticInfoImpl();
483public:
484
485};
486
488
495
496public:
498 const ProviderInfo = ...;
499
500
502 constructor(*hash<auto> options) ;
503
504
506
509
510
512
515
516
517protected:
518 hash<DataProviderInfo> getStaticInfoImpl();
519public:
520
521};
522
524class FilePollerFileEventInfoDataType : public HashDataType {
525
526public:
528 const Fields = ...;
529
530
533
534};
535
538
540class FilePollerDataProviderFactory : public AbstractDataProviderFactory {
541
542public:
543protected:
545 static Class cls = new Class("FileDelayedPollerDataProvider");
546
548 const FactoryInfo = ...;
549
550
551public:
552
554
556protected:
557 hash<DataProviderFactoryInfo> getInfoImpl();
558public:
559
560
562
564protected:
565 hash<DataProviderInfo> getProviderInfoImpl();
566public:
567
568
570protected:
572public:
573
574};
575};
576
577// private namespace; not exported
578namespace Priv {
579class EmbeddedFilePoller : public FilePoller {
580
581public:
582protected:
584 Observable observable;
585
586public:
587
588 constructor(FilePollerDataProviderBase provider, string path, string mask, *hash<auto> options) ;
589
590
591 singleFileEvent(hash<auto> event);
592
593};
594
595const FileWhiteLogo = ...;
596
597
598const FileBlackLogo = ...;
599
600}
Event-based data provider for file polling events.
Definition FilePoller.qm.dox.h:494
constructor(*hash< auto > options)
Creates the object from constructor options.
observersReady()
Called when all observers have been added to the object.
stopEvents()
Called to stop generating events.
const ProviderInfo
Provider info.
Definition FilePoller.qm.dox.h:498
Event-based data provider for file events.
Definition FilePoller.qm.dox.h:418
*string getDesc()
Returns the data provider description.
EmbeddedFilePoller poller
The file poller itself.
Definition FilePoller.qm.dox.h:427
hash< string, hash< DataProviderMessageInfo > > getEventTypesImpl()
Returns a hash of all supported event types.
constructor(*hash< auto > options)
Creates the object from constructor options.
const ConstructorOptions
Constructor options.
Definition FilePoller.qm.dox.h:422
updateConnectionObjects(object conn, object connobj)
Update any connection used by the data provider.
The file poller data provider factory.
Definition FilePoller.qm.dox.h:540
const FactoryInfo
Factory info.
Definition FilePoller.qm.dox.h:548
hash< DataProviderFactoryInfo > getInfoImpl()
Returns static factory information without provider_info.
Class getClassImpl()
Returns the class for the data provider object.
static Class cls
Data provider type info.
Definition FilePoller.qm.dox.h:545
hash< DataProviderInfo > getProviderInfoImpl()
Returns static provider information.
Event-based data provider for file polling events.
Definition FilePoller.qm.dox.h:470
constructor(*hash< auto > options)
Creates the object from constructor options.
const ProviderInfo
Provider info.
Definition FilePoller.qm.dox.h:474
File poller event data description.
Definition FilePoller.qm.dox.h:524
const Fields
Markdown descriptions for hashdecl members.
Definition FilePoller.qm.dox.h:528
*softint minage
minimum file age in seconds before the file will be included in the list returned
Definition FilePoller.qm.dox.h:215
*code log_info
optional info log closure
Definition FilePoller.qm.dox.h:218
logDebug(string fmt,...)
calls "log_debug" with verbose debugging information; if set
int reopt
regex options
Definition FilePoller.qm.dox.h:212
int start()
starts polling in the background; returns the thread ID of the polling thread
const SortNone
no sorting
Definition FilePoller.qm.dox.h:163
string path
path to monitor
Definition FilePoller.qm.dox.h:179
constructor(string n_path, string n_mask, *hash< auto > n_opts)
creates the object
*code log_debug
optional debug log closure
Definition FilePoller.qm.dox.h:224
int tid
polling tid
Definition FilePoller.qm.dox.h:206
destructor()
stops the polling operation if in progress and destroys the object
*code log_detail
optional detail log closure
Definition FilePoller.qm.dox.h:221
list< hash< FilePollerFileEventInfo > > getFiles(int sort=FilePoller::SortNone, int order=FilePoller::OrderAsc)
returns a list of regular file hashes matching any file name mask set for the object
const OrderAsc
ascending sort order
Definition FilePoller.qm.dox.h:158
int getPollCount()
returns the current poll count
setPath(string path)
Changes the polling path.
waitStop()
Waits indefinitely for the polling operation to stop.
abstract singleFileEvent(hash< FilePollerFileEventInfo > event)
called for each matching file individually when matching files are polled
Qore::Thread::Counter sc()
stop counter
string mask
file name mask
Definition FilePoller.qm.dox.h:182
run()
starts the polling operation
startInline()
starts the polling operation inline (not in a background thread)
stop()
stops the polling operation, returns when the polling operation has been stopped
bool runOnce()
runs a single poll (useful for checking for errors inline before starting a background thread)
*code sleep
optional sleep closure
Definition FilePoller.qm.dox.h:230
logDetail(string fmt,...)
calls "log_detail" with detail information; if set
stopNoWait()
stops the polling operation, returns immediately
Qore::Thread::Mutex m()
start mutex
static checkPath(string path, string type, bool write=False)
checks a path on the server file system
*code start_thread
optional start thread closure
Definition FilePoller.qm.dox.h:227
fileEvent(list< hash< FilePollerFileEventInfo > > files)
Called for each poll event with a list of all files matched.
fileSleep(softint secs)
sleeps for the specificed number of seconds
logInfo(string fmt,...)
calls "log_info" with important information, if set
Main module namespace.
Definition FilePoller.qm.dox.h:72
const AppName
Generic app name for the server filesystem.
Definition FilePoller.qm.dox.h:74
const EVENT_FILE
File event constant.
Definition FilePoller.qm.dox.h:77
FilePoller file event hash.
Definition FilePoller.qm.dox.h:80
date ctime
The created date/time of the file.
Definition FilePoller.qm.dox.h:114
int nlink
The number of hard links to this file.
Definition FilePoller.qm.dox.h:93
int mode
The file protection mode.
Definition FilePoller.qm.dox.h:90
int inode
The inode of the file.
Definition FilePoller.qm.dox.h:85
string type
the type of file
Definition FilePoller.qm.dox.h:138
string name
The name of the file, link, or directory.
Definition FilePoller.qm.dox.h:144
int dev
The device inode number the file is on.
Definition FilePoller.qm.dox.h:82
int blocks
Blocks allocated for the file.
Definition FilePoller.qm.dox.h:124
int uid
The UID of the owner of the file.
Definition FilePoller.qm.dox.h:96
int blksize
Block size.
Definition FilePoller.qm.dox.h:119
date atime
The last accessed date/time of the file.
Definition FilePoller.qm.dox.h:108
int rdev
The device type number.
Definition FilePoller.qm.dox.h:102
string perm
a string giving UNIX-style permissions for the file (ex: "-rwxr-xr-x")
Definition FilePoller.qm.dox.h:141
int gid
The GID of the owner of the file.
Definition FilePoller.qm.dox.h:99
int size
The size of the file in bytes.
Definition FilePoller.qm.dox.h:105
*string link
symbolic link target (if present)
Definition FilePoller.qm.dox.h:150
string filepath
The entire path of the file.
Definition FilePoller.qm.dox.h:147
date mtime
The last modified date/time of the file.
Definition FilePoller.qm.dox.h:111