mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-28 20:13:33 +00:00
feat(distlock): refactor into a standalone package
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package distlock
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Store holds node-local lease state and provides atomic operations over it.
|
||||
type Store interface {
|
||||
// Acquire creates a lease when the resource does not have an unexpired lease.
|
||||
Acquire(ctx context.Context, resource string, token []byte, ttl time.Duration) (bool, error)
|
||||
// Renew extends an unexpired lease when its ownership token matches.
|
||||
Renew(ctx context.Context, resource string, token []byte, ttl time.Duration) (bool, error)
|
||||
// Release removes a lease when its ownership token matches.
|
||||
Release(ctx context.Context, resource string, token []byte) (bool, error)
|
||||
}
|
||||
Reference in New Issue
Block a user