-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support redis lock automatic renewal #55
Conversation
redislock.go
Outdated
@@ -24,30 +25,31 @@ var ( | |||
|
|||
// NewRedisLocker provides an implementation of the Locker interface using | |||
// redis for storage. | |||
func NewRedisLocker(r redis.UniversalClient, options ...redsync.Option) (gocron.Locker, error) { | |||
func NewRedisLocker(r redis.UniversalClient, autoExtendDuration time.Duration, options ...redsync.Option) (gocron.Locker, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a breaking change (so let's not do it this way). An oversight on my part to have the options be ...resync.Option instead of a gocron.RedisLockerOption, to which we could just add WithAutoExtendDuration.
Instead, let's do it the way it should have been:
- Add a new method
func NewRedisLockerWithOptions(r redis.UniversalClient, options ...LockerOption) (gocron.Locker, error)
- Define the LockerOption as
type LockerOption func(*redisLocker) error
- Then, we could define all the options, with
Option
appended to the name so they are unique, as LockerOption type - Then, also add
WithAutoExtendDuration
as an Option and implement it through there.
Let me know if you would like to complete this work. If not, I will take it on when I have time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some changes:
- Add
LockOption
, supportWithAutoExtendDuration
,WithRedsyncOptions
to be compatible with redsync options - Added
NewRedisLockerWithOptions
- Modified
TestAutoExtend
Please review it again.
Can you create a new tag? @JohnRoesler |
Hi @JohnRoesler, sorry to bother, why this pr doesn't apply to the latest v2? |
@Sora233 it was added after I started the v2 branch. Feel free to make the same PR to the v2 branch - i will approve 👍 |
What does this do?
Support redis lock automatic renewal
Which issue(s) does this PR fix/relate to?
#54
List any changes that modify/break current functionality
Have you included tests for your changes?
TestAutoExtend
Did you document any new/modified functionality?
example_test.go
README.md
Notes