refactor(exclusive_locker): Interval readability batch of updates (#3668)

* refactor(filechunk_manifest): `localProcesed` -> `localProcessed`

Signed-off-by: Ryan Russell <git@ryanrussell.org>

* refactor: `saveChunkedFileIntevalToStorage` -> `saveChunkedFileIntervalToStorage`

Signed-off-by: Ryan Russell <git@ryanrussell.org>

* refactor: `SafeRenewInteval` -> `SafeRenewInterval`

Signed-off-by: Ryan Russell <git@ryanrussell.org>

* refactor: `InitLockInteval` -> `InitLockInterval`

Signed-off-by: Ryan Russell <git@ryanrussell.org>

* refactor: `RenewInteval` -> `RenewInterval`

Signed-off-by: Ryan Russell <git@ryanrussell.org>

Signed-off-by: Ryan Russell <git@ryanrussell.org>
This commit is contained in:
Ryan Russell
2022-09-14 12:29:55 -05:00
committed by GitHub
parent e22335ba78
commit 72d8a9f9a8
3 changed files with 14 additions and 14 deletions

View File

@@ -11,9 +11,9 @@ import (
)
const (
RenewInteval = 4 * time.Second
SafeRenewInteval = 3 * time.Second
InitLockInteval = 1 * time.Second
RenewInterval = 4 * time.Second
SafeRenewInterval = 3 * time.Second
InitLockInterval = 1 * time.Second
)
type ExclusiveLocker struct {
@@ -37,7 +37,7 @@ func (l *ExclusiveLocker) IsLocked() bool {
}
func (l *ExclusiveLocker) GetToken() (token int64, lockTsNs int64) {
for time.Unix(0, atomic.LoadInt64(&l.lockTsNs)).Add(SafeRenewInteval).Before(time.Now()) {
for time.Unix(0, atomic.LoadInt64(&l.lockTsNs)).Add(SafeRenewInterval).Before(time.Now()) {
// wait until now is within the safe lock period, no immediate renewal to change the token
time.Sleep(100 * time.Millisecond)
}
@@ -68,7 +68,7 @@ func (l *ExclusiveLocker) RequestLock(clientName string) {
return err
}); err != nil {
println("lock:", err.Error())
time.Sleep(InitLockInteval)
time.Sleep(InitLockInterval)
} else {
break
}
@@ -101,7 +101,7 @@ func (l *ExclusiveLocker) RequestLock(clientName string) {
l.isLocked = false
return
} else {
time.Sleep(RenewInteval)
time.Sleep(RenewInterval)
}
}