App::PerlWatcher::Watcher - Observes some external source of events and emits the result of polling them
version 0.20
Holds an reference to engine config (used in construction watcher's thresholds_map)
Remembers the arguments for watcher construction (used in construction watcher's thresholds_map and unique_id)
The wacher configuration hash ref.
Represents watchers unique_id, calculated from concrete watcher class and watcher's config. The unique_id is overloaded "to-string" operation, so watcher can be used to as hash key. unique_id is also used when the PerlWatcher state is been persisted : the watcher itself isn't stored, but it's unique_id is stored. That guarantees that unique_id is the same between PerlWatcher invokations (that's why the perl internal hash funciton isn't used)
Memorizable attribute, defines, weather the current watcher is active
The memorizable map, which represents how to interpret successul or unsuccessful result, i.e. which level of severity it is. It looks like:
my $map = { fail => { 3 => 'info', 5 => 'alert', }, ok => { 3 => 'notice' }, };
Represents last emitted watcher status
The subroutine reference, which is been called before every poll of watcher external source.
$watcher->poll_callback($watcher);
The subroutine reference, which is been called after every poll of watcher external source. It's argument is the State, i.e.
$watcher->callback($state)
The watcher guard returned by AnyEvent->io, AnyEvent->timer etc, with is an core under wich the Watcher is been build.
The method is responsible for building watcher_guard
Immediatly polls the watched object.
Turns on and off the wacher, remembering the state in memory
Starts the watcher, which will emit it's statuses. The watcher will start only it is active.
Calculates the thresholds_map based on the left map and righ map The left map has precedence. Usualy the left map is the watchers config, while the righ map is the generic PerlWatcher/Engine config
This method interprets the result of poll (true or false) in accordance with thresholds_map and the callback will be called with the resulting status (and optionally provided items). Meant to be called from subclases, e.g.
$watcher->interpret_result(0, $callback);
The items can be tacken from the previous result interpreation if they match by content
$items is an coderef, which actually returns array of items.
Ivan Baidakou <dmol@gmx.com>
This software is copyright (c) 2013 by Ivan Baidakou.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install App::PerlWatcher::Engine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::PerlWatcher::Engine
CPAN shell
perl -MCPAN -e shell install App::PerlWatcher::Engine
For more information on module installation, please visit the detailed CPAN module installation guide.