antirez / antirez/redlock-rb

Is it desired behavior to sleep, even after the last retry in the lock function?

Đang mở
#7 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Ruby
Star
213
Fork
24
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

If a lock was _not_ obtained in the lock function, is it desired behavior to sleep (in line 80), even after the last retry?
I think that the last retry's sleep will be a waste of time, if the lock was not obtained.
https://github.com/antirez/redlock-rb/blob/97be08b307eaad7f9b23db41e8def691ea41a342/redlock.rb#L55-L57
https://github.com/antirez/redlock-rb/blob/97be08b307eaad7f9b23db41e8def691ea41a342/redlock.rb#L79-L81

If my argument holds, how about:
```
for i in 0..(retry_count-1)

# The major part of the lock function goes here.

# Don't sleep if it's the last retry.
if (i != retry_count-1)
# Wait a random part of retry_delay, before retrying.
sleep(rand(@retry_delay).to_f/1000)
end
end
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.