Remote locks implementation, fixes #525

This commit is contained in:
DanB
2016-10-06 20:01:56 +02:00
parent 5eff7d9ed4
commit 6024cfff98

View File

@@ -24,6 +24,7 @@ import (
"path"
"strconv"
"strings"
"time"
"github.com/cgrates/cgrates/cache2go"
"github.com/cgrates/cgrates/config"
@@ -1078,3 +1079,20 @@ func (self *ApierV1) RemoveActions(attr AttrRemoveActions, reply *string) error
*reply = utils.OK
return nil
}
type AttrRemoteLock struct {
LockIDs []string // List of IDs to obtain lock for
Timeout time.Duration // Automatically unlock on timeout
}
func (self *ApierV1) RemoteLock(attr AttrRemoteLock, reply *string) error {
engine.Guardian.GuardIDs(attr.Timeout, attr.LockIDs...)
*reply = utils.OK
return nil
}
func (self *ApierV1) RemoteUnlock(lockIDs []string, reply *string) error {
engine.Guardian.UnguardIDs(lockIDs...)
*reply = utils.OK
return nil
}