type ServerLockService struct {
SQLStore db.DB// contains filtered or unexported fields
}
ServerLockService allows servers in HA mode to claim a lock and execute a function if the server was granted the lock
It exposes 2 services LockAndExecute and LockExecuteAndRelease, which are intended to be used independently, don't mix
them up (ie, use the same actionName for both of them).
LockAndExecute try to create a lock for this server and only executes the
`fn` function when successful. This should not be used at low internal. But services
that needs to be run once every ex 10m.
LockExecuteAndRelease Creates the lock, executes the func, and then release the locks. The locking mechanism is
based on the UNIQUE constraint of the actionName in the database (column operation_uid), so a new process can not insert
a new operation if already exists one. The parameter 'maxInterval' is a timeout safeguard, if the LastExecution in the
database is older than maxInterval, we will assume the lock as timeouted. The 'maxInterval' parameter should be so long
that is impossible for 2 processes to run at the same time.