13 lines
299 B
Go
13 lines
299 B
Go
package locker
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
type Locker interface {
|
|
Lock(ctx context.Context, id string, ttl time.Duration) (bool, error)
|
|
Unlock(ctx context.Context, id string) error
|
|
WithLock(ctx context.Context, lockKey string, lockTime time.Duration, fn func(context.Context) error) error
|
|
}
|