mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
refactor: simplify serverlock code (#37451)
This commit is contained in:
parent
0d2aaed3e8
commit
6aa2a0dc8a
@ -39,7 +39,7 @@ func (sl *ServerLockService) LockAndExecute(ctx context.Context, actionName stri
|
|||||||
// avoid execution if last lock happened less than `maxInterval` ago
|
// avoid execution if last lock happened less than `maxInterval` ago
|
||||||
if rowLock.LastExecution != 0 {
|
if rowLock.LastExecution != 0 {
|
||||||
lastExecutionTime := time.Unix(rowLock.LastExecution, 0)
|
lastExecutionTime := time.Unix(rowLock.LastExecution, 0)
|
||||||
if lastExecutionTime.Unix() > time.Now().Add(-maxInterval).Unix() {
|
if time.Since(lastExecutionTime) < maxInterval {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user