Add resource locking 06/706/1 v0.3.0
authorMarco Tallskog <marco.tallskog@nokia.com>
Wed, 14 Aug 2019 11:50:23 +0000 (14:50 +0300)
committerMarco Tallskog <marco.tallskog@nokia.com>
Wed, 14 Aug 2019 12:01:26 +0000 (15:01 +0300)
commita10caff26de79e06caac2d00d3c11218e2d7ee87
tree2b37e0513f3a2976cdc3d82e42f1a5a9cd6a8712
parentae7460ab662366115f6decc834a109bfa8985cc6
Add resource locking

Implement methods that enable applications to create locks for
a resources. Resource locks are plain keys with a random value
with an expiration time. Only the holder of a lock can release it either
by removing the lock or by letting it expire (after it will be
automatically removed). By using a random value (that only lock holder
knows), it can be ensured that others can't remove it. Resource locks
are per namespace.

Implemented methods are:
LockResource: this method will check if the lock already exists and if
not, it will create it with an expiration time. It is possible for the
client to define with options how many times the lock will be tried and
the interval how often it is tried. If retry is used, this method will
block.
ReleaseResource: remove the lock. If removing is tried after the
expiration, an error will be returned.
RefreshResource: with this method, it is possible to set a new
expiration time for the lock. If the lock has already expired, an error
will be returned.
CheckResource: application can query the remaining expiration time with
this method, regardless it is the owner of the lock or not.

Change-Id: Ic6f5274c1740c7e36ddaba564024cffcc4c5de3d
Signed-off-by: Marco Tallskog <marco.tallskog@nokia.com>
internal/sdlgoredis/sdlgoredis.go
internal/sdlgoredis/sdlgoredis_test.go
sdl.go
sdl_test.go