mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 13:19:53 +05:00
Remote locks implementation, fixes #525
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user