refactor: use time.Ticker
This commit is contained in:
parent
ea4a22c52d
commit
43c4590439
|
@ -80,13 +80,17 @@ func (l *Lock) Lock(ctx context.Context, requestUnlock func()) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
ticker := time.NewTicker(l.holderPollInterval)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-l.stopHolderPoll:
|
case <-l.stopHolderPoll:
|
||||||
return
|
return
|
||||||
case <-time.After(l.holderPollInterval):
|
case <-ticker.C:
|
||||||
requested, err := l.lockRecord.IsReleaseRequested(db)
|
requested, err := l.lockRecord.IsReleaseRequested(db)
|
||||||
if err == nil {
|
if err != nil {
|
||||||
|
// Handle error
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue