Add lock expiry handler to expire state locks (#8562)

This commit is contained in:
Harshavardhana
2019-11-25 16:39:43 -08:00
committed by GitHub
parent e542084c37
commit 720442b1a2
7 changed files with 182 additions and 7 deletions

View File

@@ -47,6 +47,8 @@ func toLockError(err error) error {
switch err.Error() {
case errLockConflict.Error():
return errLockConflict
case errLockNotExpired.Error():
return errLockNotExpired
}
return err
}
@@ -109,7 +111,7 @@ func (client *lockRESTClient) restCall(call string, args dsync.LockArgs) (reply
switch err {
case nil:
return true, nil
case errLockConflict:
case errLockConflict, errLockNotExpired:
return false, nil
default:
return false, err
@@ -136,6 +138,11 @@ func (client *lockRESTClient) Unlock(args dsync.LockArgs) (reply bool, err error
return client.restCall(lockRESTMethodUnlock, args)
}
// Expired calls expired handler to check if lock args have expired.
func (client *lockRESTClient) Expired(args dsync.LockArgs) (expired bool, err error) {
return client.restCall(lockRESTMethodExpired, args)
}
func closeLockers(lockers []dsync.NetLocker) {
for _, locker := range lockers {
locker.Close()