Documentation
¶
Overview ¶
Package flocklease is the single-host port.SessionLease implementation. It combines the generic expiry contract with immediate same-host crash detection: a stable per-session flock serializes record transitions only, while each lease generation retains its own liveness flock for the generation's lifetime.
Layout per session id <safeID> under the lease dir:
- <safeID>.lock — stable, operation-scoped transition lock.
- <safeID>.<token>.live — generation-specific retained liveness lock.
- <safeID>.lease.json — atomic {owner, token, expiry} record.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lease ¶
type Lease struct {
// contains filtered or unexported fields
}
Lease is a single-host port.SessionLease over a lease directory.
func New ¶
New constructs a single-host lease rooted at dir. A non-positive ttl defaults to 30 seconds.
func (*Lease) Acquire ¶
func (l *Lease) Acquire(ctx context.Context, id session.SessionID, owner string) (out port.Lease, err error)
Acquire serializes the record transition under the stable lock. An unexpired record is held only while its generation lock is live; a crashed holder can be replaced immediately. An expired record can always be replaced, even if its old process remains alive.
func (*Lease) Release ¶
Release tombstones and closes only the exact current generation. A stale release cannot alter or unlock a successor. If writing or closing fails, the retained handle remains tracked so a later call can retry cleanup.