feat(distlock): refactor into a standalone package

This commit is contained in:
Pasha Sviderski
2026-08-27 15:49:59 +10:00
parent 7a7a313426
commit 613cd6e418
10 changed files with 148 additions and 142 deletions
+16
View File
@@ -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)
}