feat(distlock): implement in-memory lease store

This commit is contained in:
Pasha Sviderski
2026-08-26 16:53:21 +10:00
parent 5a956e72de
commit a5ab6e3788
4 changed files with 403 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
package distlock
import (
"context"
"time"
)
// Store holds machine-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)
}