Should here return `context.Cause(ctx)` or the error warp with `context.Cause(ctx)` when `ctx.Done()` ?
Closed this issue · 2 comments
spike014 commented
Lines 88 to 93 in 9348b33
Should here return context.Cause(ctx)
or the error warp with context.Cause(ctx)
when ctx.Done()
?
Because ctx
may contain the CancelCause
which inside the user's parent context generated by context.WithCancelCause
.
I will contribute a PR later. If there is any problem, please let me know.
spike014 commented
context.Cause(ctx)
and WithCancelCause
is new after Go1.20.
I think the issue should return to :
Should here return ctx.Err() or the error warp with ctx.Err() when ctx.Done() ?
The ctx
may with timeout setting.
I think here may let user know why he/she didn't get the lock when the ctx's deadline passes or canceled by someone.
Then the error can be deal with the way like this:
if err == context.DeadlineExceeded {
log.Println("context timeout error", err)
// or do something else
// Timeout~
} else if err == context.Canceled {
// Oh! Somebody cancaled this context. That is NOT the error from `bsm/redislock`.
}