NAME
App::OverWatch::ServiceLock - ServiceLock base class
VERSION
version 0.1
SYNOPSIS
use App::OverWatch;
my $OverWatch = App::OverWatch->new();
[...]
my $ServiceLock = $OverWatch->ServiceLock();
DESCRIPTION
Provides a simple mechanism for allowing the locking of named resources via a central database. Locks can have expiry periods, so could perhaps be considered leases.
NAME
App::OverWatch::ServiceLock - App::OverWatch Locking System
METHODS
new
Create an App::OverWatch::EventLog object - usually handled by App::OverWatch.
create_lock
Create a lock
$ServiceLock->create_lock({
system => $system,
})
get_all_locks
Return a list of App::OverWatch::Lock objects representing all created locks.
my @Locks = $ServiceLock->get_all_locks();
get_lock
Return an App::OverWatch::Lock object for a given lock.
my $Lock = $ServiceLock->get_lock({
system => $Options->{system},
});
try_lock
Attempt to gain a lock.
$ServiceLock->try_lock({
system => $system,
worker => 'myworkerid',
text => 'Why we want the lock',
expiry => $expiry_in_minutes, # Optional
});
Returns 1 on success, 0 otherwise.
try_update
Attempt to update details of a lock in place. This can only succeed if the worker already owns the lock.
$ServiceLock->try_update({
system => $system,
worker => 'myworkerid',
text => 'New text',
expiry => $new_expiry_in_minutes,
});
try_unlock
Attempt to release a lock.
$ServiceLock->try_unlock({
system => $system,
worker => 'myworkerid',
});
force_unlock
Force a lock to be released.
$ServiceLock->force_unlock({
system => $system,
});
AUTHOR
Chris Hughes <chrisjh@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2015 by Chris Hughes.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.