ExclusiveFenced

Distributed lock with monotonically increasing fence counter. Background goroutine renews the lease at ttl/3; if renewal fails, the action context is canceled immediately to abort in-flight work. The handler can retrieve the lease and pass the fence to downstream storage.

t=0t→Acquirefence=NRenewttl/3Renew2·ttl/3Renew FAILlease lostcancel ctxaborthandler executing with lease.Fence=Nlease retrieved via action.LeaseFromContext(ctx)downstream storage MUST validate fenceUPDATE ledger SET ... WHERE fence >= @lease.FenceLease renewal at ttl/3 · loss → immediate ctx cancellation

Signature

action contract
.ExclusiveFenced(m FencedMutex, ttl time.Duration, keyFn func(Req) string) *Builder[Req, Res]