redis lock
This commit is contained in:
parent
ec15531eac
commit
44ca97b7d0
|
|
@ -2,6 +2,7 @@ package lock
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"time"
|
||||
)
|
||||
|
|
@ -21,7 +22,7 @@ func (c *Mutex) Lock(ctx context.Context, resource string, callback func(ctx con
|
|||
l := c.locker.GetLock(resource)
|
||||
|
||||
if err := l.Lock(ctx); err != nil {
|
||||
return err
|
||||
return fmt.Errorf("lock failed: %w", err)
|
||||
}
|
||||
defer func() {
|
||||
_ = l.Unlock(ctx)
|
||||
|
|
|
|||
Loading…
Reference in New Issue