ZooKeeper::Dispatcher
A parent class for event dispatchers to inherit from. Dispatchers directly handle callbacks for ZooKeeper the C library, and manage the lifecycle of ZooKeeper::Watcher's.
A ZooKeeper::Channel, used for sending event data from ZooKeeper C callbacks to perl.
A hashref of all live watchers.
The perl subroutine reference to be invoked whenever the dispatcher is notified of an event. Usually just calls dispatch_event.
Controls whether watchers should be triggered for session events.
Receive event data from the channel. Returns undef if no event data is available.
Create a new ZooKeeper::Watcher. This is the preferred way to instantiate watchers.
my $watcher = $dispatcher->create_watcher($path, $cb, %args); REQUIRED $path - The path of the node to register the watcher on REQUIRED $cb - A perl subroutine reference to be invoked with event data %args REQUIRED type - The type of event the watcher is for(e.g get_children, exists)
Read an event from the channel, and execute the corresponding watcher callback.
Manually trigger an event on a ZooKeeper::Watch.
Synchronously dispatch one event. Returns the event hashref the watcher was called with. Can optionally be passed a timeout(specified in seconds), which will cause wait to return undef if it does not complete in the specified time.
my $event = $zk->wait($seconds) OPTIONAL $seconds
To install ZooKeeper, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ZooKeeper
CPAN shell
perl -MCPAN -e shell install ZooKeeper
For more information on module installation, please visit the detailed CPAN module installation guide.