ServerMutex extension

Short-lived locks shared by every client of an atSign, held on its atServer.

A lock is an immutable self record with a ttl. The atServer refuses to create it a second time until the ttl runs out, so of all the clients that ask for it, exactly one gets a lease. Nothing releases a lock early: its ttl is the only release.

Locks are written straight to the atServer, never to the local store, and with :nc, so they reach no client's sync.

Locks need an atServer from p3.13.0 (at_commons 5.10.0), the first to parse :nc; an older one refuses every lock, and tryAcquireServerMutex throws. The record stays out of the commit log from c3.16.3 and p3.16.5; between p3.13.0 and those the atServer records the commit anyway. An expired lock stops blocking at once from c3.16.2 and p3.16.5; before that it blocks until the atServer's expiry sweep, up to about ten and a half minutes.

on

Methods

tryAcquireServerMutex(AtKey key, {required Duration ttl}) → Future<ServerMutexLease?>

Available on AtClient, provided by the ServerMutex extension

Takes the lock key names for ttl, or returns null when an immutable record already exists at key; a mutable record there is overwritten and taken.